Or another alternative is to create some runnable script and run it
against the environment you want:
$ cat ./script/do_some_foo.runnable
puts " fetching all foo in #{RAILS_ENV} env:"
Foo.find(:all).each do |foo|
// do something with foo ...
end
...
$ ./script/runner ./script/do_some_foo.runnable
fetching all foo in development env:
...
$ ./script/runner -e production ./script/do_some_foo.runnable
fetching all foo in production env:
...
Jeff
On Jun 19, 12:23 pm, Frederick Cheung <[email protected]>
wrote:
> On Jun 19, 7:55 pm, Philip Hallstrom <[email protected]> wrote:> class Foo
> > def self.bar
> > # do whatever you want to do and have access to all your models,
> > etc.
> > end
> > end
>
> > And run it with "./script/runner Foo.bar"
>
> > You could also do it as a rake task and have rake load up the
> > environment...
>
> Or require config/environment
>
> Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---