views:

83

answers:

1

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

+1  A: 

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
i still get db/load.rb:2: uninitialized constant Quiz (NameError)
Tony
Have you set up your database.yml file and run your database migrations yet?rake db:migrate
jdl
nevermind that worked, stupid error on my part. thanks a lot
Tony
You're welcome. Good luck with your app.
jdl