0
votes

I want to add a new attribute "usertype" to User. I followed the answer in the following link:

Extending the Spree::Product model/class

I created a new migration and also created a file "spree/user_decorator.rb", which has the codes:

Spree::User.class_eval
  attr_accesssible :usertype
end

But when I run "rails s", it says I have "syntax error, unexpected keyword_end, expecting end-of-input (SyntaxError)" in this file.

What's wrong with the three lines of codes?

PS: I also tried

Spree::User.class_eval do
  attr_accesssible :usertype
end

Then it says the method attr_accesssible does not exist.

1

1 Answers

0
votes

Your first code sample is syntactically incorrect. Your second code sample is the correct syntax.

attr_accessible is no longer used in Rails 4, which is used by Spree 2.1 and later. You should look in to adding the attribute to Spree's PermittedAttributes instead.