lundi 16 juillet 2018

Uninitialized constant Spree::User after creating attributes in model

I added two attributes to my model:

#group.rb

class Spree::Group < ActiveRecord::Base
    has_many :users
end

#user_decorator.rb
Spree::User.class_eval do
  belongs_to :group, class_name: "Spree::Group"
end

I created a new spree folder in my models directory and created a file for group.rb and user_decorator.rb and added the code then ran:

bundle exec rake:db migrate

I then recived this error:

NameError: uninitialized constant Spree::User

I'm unsure of how to fix this error and wonder if it is because I just added the attributes to my model.

1 commentaire: