0

I have a seed script called load.rb in the db directory of an application. I just got this app from a client so not sure how to run this script. I get a name error on all of the Model.create(...) statements. I guess this is because the Rails environment is not loaded.

There is no indication that this load script was run via a rake task because I see no custom rake tasks in the app. Is this a "Rails thing"? ...in other words, is there a command I am not aware of that will load the app context and execute load.rb in the db directory?

If not, how can load the app context in the file so that I can simply type "ruby load.rb" to load the database?

The file is literally just a bunch of create statements:

Quiz.create(:name=> "1")
Quiz.create(:name=> "2")
Quiz.create(:name=> "3")
Quiz.create(:name=> "4")

thanks

Tony
  • 18,776
  • 31
  • 129
  • 193

1 Answers1

1

It looks like it's probably just being run from the console. For development, you'd simply start with

./script/console

from your Rails root directory.

Then inside your console, load the script.

>> load "db/load.rb"
jdl
  • 17,702
  • 4
  • 51
  • 54