0

i wrote a script to fill a database using values from an excel page. In the script I'm getting the error

uninitialized constant Profile (NameError)

Profile is the name of a model i have. Rails looks it is not recognizing my model in the script. How can fix this.

Kevin
  • 1,574
  • 4
  • 19
  • 45

1 Answers1

0

It looks like Rails doesn't get properly initialized.

Can you post the script, and explain how you run / start it?

Which version of Rails do you use?

If you have a rails application and you want to run a task as a script, there are two ways to do it:

1) via script runner

2) via rake

If you use rake, you have to tell it to initialize your Rails application properly. The rake tasks need to be under ./lib/tasks

Check out these Posts, which explain how to do it:

I have a Rails task: should I use script/runner or rake?

script/runner in rails 3

http://guides.rubyonrails.org/active_record_querying.html

Community
  • 1
  • 1
Tilo
  • 33,354
  • 5
  • 79
  • 106