Reputation: 53
I'm trying to create a new model in spree extension. I generated a model and it is in /spree_extension/app/models/my_class.rb:
module Spree
class MyClass < Spree::Base
belongs_to :product
end
end
But when I start my application, there is no Spree::MyClass, I get this error:
NameError: uninitialized constant Spree::MyClass
I tried moving my_class.rb to "spree" directory, but nothing helps.
Upvotes: 0
Views: 279
Reputation: 53
The problem was in fact I created a table my_class
.
Since I renamed it to spree_my_class
, it works.
Upvotes: 0
Reputation: 7723
Most probably, you need to put your class into:
/spree_extension/app/models/spree/my_class.rb
As rails is always expecting to find classes inside file with the same name, inside folder that has the module name.
Upvotes: 1