I have created a Rails Engine. I am having trouble using the seed command, if I run rake db:seed I get the error: "uninitialized constant".
In the engine, I got a seeds.rb:
Page.create(:title => 'Frontpage', :order => '1')
Then in my dummy app I got a seeds.rb with
cms::Engine.load_seed
(cms being the name of the engine) -- I got an error now though, that "uninitialized constant ". How do I reference the constant from the dummy app?
Ok, got it! - the answer is:
In the engine, add a seeds.rb in the db folder, prepend the app name to each constant, like so:
Cms::Page.create(:title => 'Frontpage', :order => '1')
In the dummy app, or the app where you are adding your engine, add a seeds.rb to the db folder with:
Cms::Engine.load_seed
and run:
rake db:seed
in the terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With