-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ActionView::Template::Error (points is defined by ActiveRecord) #34
Comments
There's a recent commit in a fork which renames I'll take a look at what's happening, and if it's better I'll rename it to Thanks for your feedback! |
Meanwhile you may monkey patch ActiveRecord so you can work: http://stackoverflow.com/a/1515571/356060 ( |
I also tried with the fix for DangerousAtrributeError from the UPDATE notice[1], but did not work for me (the monkey patch method). The environment is Rails 3.1.3. [1]: If you get an ActiveRecord::DangerousAttributeError: points exception, you may need to temporarily tweak your meritable model, as explained in http://stackoverflow.com/a/1515571/356060. Thanks for your quick response. |
More: I'll rename the method name as it may collide with ActiveRecord. Anyway you may need to change that attribute name in your application: http://stackoverflow.com/questions/7718651/activerecorddangerousattributeerror |
Pretty sure it's coming from your |
I tried the Thanks for your lighting-fast responses! |
Happy it works for now! :-) But there is a design flaw inside of Rails raises I'll leave this issue open until I rework that. Thanks for the feedback! |
Understood! Thanks for the great work! |
Bummer! After adding the safe_attributes gem, there is still a problem when trying to save something over the points attribute: NameError (undefined local variable or method `sash' for #<Question:0x00000003b9b308>):
app/controllers/admin/games_controller.rb:96:in `block (2 levels) in create'
app/controllers/admin/games_controller.rb:92:in `each'
app/controllers/admin/games_controller.rb:92:in `block in create'
app/controllers/admin/games_controller.rb:69:in `create' Any idea how to hack the create method to avoid this error? EDIT: Adding to the Question model: def points
self[:points]
end
def sash
self.points
end Seems to fix it. I will continue testing this, maybe more problems can arise from this. |
Why does a Question need a sash? Is it "meritable"? If not, please paste your rules in a gist. |
It is not "meritable", but somehow when calling Question.points in the create method it asked for it. |
There's the method names collision, the reason for the exception. Merit needs to add the Maybe I can review it tomorrow or this weekend. |
Ok, tested again with the git version of merit and it seems to work fine now. I removed the code from Question that I had to add before: # def points
# self[:points]
# end
# def sash
# self.points
# end And tested create, new, save, question.points. No more annoying problems were found! Also tested user.points, adding badges/points to user, all with no problems. Thanks! |
Awesome, you may use version 1.1.0 now. |
Before adding the merit gem, I had a model with the points attribute (my Question model).
Now that gives this problem when trying to use a question in a rails form:
ActionView::Template::Error (points is defined by ActiveRecord)
And if I try to create a new Question:
Is there a way to avoid this problem without renaming the "points" attribute of my models?
Greetings,
EDIT: Adding the
gem 'safe_attributes'
to the Gemfile fixes the problem (obtained from http://stackoverflow.com/questions/7718651/activerecorddangerousattributeerror)EDIT 2: After adding the safe_attributes gem, there is still a problem when trying to save something over the points attribute:
EDIT 3: Adding to the Question model:
Seems to fix it. I will continue testing this, maybe more problems can arise from this.
The text was updated successfully, but these errors were encountered: