Jeroen Houben
2006-Feb-01 22:35 UTC
[Rails] how to create a command line script that acts on a model?
Hi, I''m looking to create a ruby script that loads a bunch of records and manipulates these. Where do I start? I got this to begin with: #!/usr/bin/env ruby require File.dirname(__FILE__) + ''/../config/boot'' players = Player.find :all But it complains about a DB connection. How do I set this up? Jeroen
Warren Noronha
2006-Feb-01 22:56 UTC
[Rails] how to create a command line script that acts on a model?
#!/usr/bin/env ruby require File.dirname(__FILE__) + ''/../config/boot'' require File.dirname(__FILE__) + ''/../config/environment'' ActiveRecord::Base.establish_connection (ActiveRecord::Base.configurations["development"]) user = User.find(:first) puts user.to_yaml Warren On 01-Feb-06, at 2:34 PM, Jeroen Houben wrote:> Hi, > > I''m looking to create a ruby script that loads a bunch of records > and manipulates these. Where do I start? > > I got this to begin with: > #!/usr/bin/env ruby > require File.dirname(__FILE__) + ''/../config/boot'' > > players = Player.find :all > > But it complains about a DB connection. How do I set this up? > > > Jeroen > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsBest Regards, Warren Noronha. GNU (http://www.gnu.org.in)
Warren Noronha
2006-Feb-01 22:57 UTC
[Rails] how to create a command line script that acts on a model?
#!/usr/bin/env ruby require File.dirname(__FILE__) + ''/../config/boot'' require File.dirname(__FILE__) + ''/../config/environment'' ActiveRecord::Base.establish_connection (ActiveRecord::Base.configurations["development"]) user = User.find(:first) puts user.to_yaml Warren On 01-Feb-06, at 2:34 PM, Jeroen Houben wrote:> Hi, > > I''m looking to create a ruby script that loads a bunch of records > and manipulates these. Where do I start? > > I got this to begin with: > #!/usr/bin/env ruby > require File.dirname(__FILE__) + ''/../config/boot'' > > players = Player.find :all > > But it complains about a DB connection. How do I set this up? > > > Jeroen > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsBest Regards, Warren Noronha. GNU (http://www.gnu.org.in)
Alex Young
2006-Feb-01 23:12 UTC
[Rails] how to create a command line script that acts on a model?
Jeroen Houben wrote:> Hi, > > I''m looking to create a ruby script that loads a bunch of records and > manipulates these. Where do I start?script/runner your_script_here.rb -- Alex
Jeroen Houben
2006-Feb-02 08:51 UTC
[Rails] how to create a command line script that acts on a model?
Alex Young wrote:> Jeroen Houben wrote: >> Hi, >> >> I''m looking to create a ruby script that loads a bunch of records and >> manipulates these. Where do I start? > > script/runner your_script_here.rb >It doesn''t seem to take a file as an argument, just a string.. Jeroen
Alex Young
2006-Feb-02 09:13 UTC
[Rails] how to create a command line script that acts on a model?
Jeroen Houben wrote:> Alex Young wrote: >> Jeroen Houben wrote: >>> Hi, >>> >>> I''m looking to create a ruby script that loads a bunch of records and >>> manipulates these. Where do I start? >> >> script/runner your_script_here.rb >> > > It doesn''t seem to take a file as an argument, just a string..... Ok... script/runner ''require "your_script_here"'' -- Alex
Jeroen Houben
2006-Feb-02 10:52 UTC
[Rails] how to create a command line script that acts on a model?
Alex Young wrote:> Jeroen Houben wrote: >> Alex Young wrote: >>> Jeroen Houben wrote: >>>> Hi, >>>> >>>> I''m looking to create a ruby script that loads a bunch of records >>>> and manipulates these. Where do I start? >>> >>> script/runner your_script_here.rb >>> >> >> It doesn''t seem to take a file as an argument, just a string.. > ... Ok... > > script/runner ''require "your_script_here"'' >Why didn''t I think of that?? Anyway, thanks for you help, this works perfectly! Jeroen