I have to run this script: /scripts/saveData.rb
And in it, I need to use ActiveRecord of my Rails application.
I tried to invoke Class, but I get error "uninitialized constant (NameError)".
How can I get a reference to the Rails classes from my saveData.rb script?
Rails 3.1
UPDATED: how i can invoke a method of a Model? My model is: “Program” (also Active Record). I tried with “Program.method” but it doesnt works, why?
Which version of rails you are using?
You can run your code in Rails runner like this if you are using Rails 3:
http://guides.rubyonrails.org/command_line.html#rails-runner
If you are using Rails 2, try this one: