-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Close #797 #876
Close #797 #876
Conversation
08b64d8
to
cfd3879
Compare
This needs a CHANGELOG entry please, and possible documentation in README. |
1bf69a5
to
7668a22
Compare
Added. |
Merged, thanks. |
Mash does not seem to play well with Rails::StrongParameters, because of the reimplementation of #respond_to?:
Rails::StrongParameters utilizes the #sanitize_for_mass_assignment method, which raises an module ActiveModel
class ForbiddenAttributesError < StandardError
end
module ForbiddenAttributesProtection
protected
def sanitize_for_mass_assignment(attributes)
if attributes.respond_to?(:permitted?) && !attributes.permitted?
raise ActiveModel::ForbiddenAttributesError
else
attributes
end
end
end
end This results in always raising a ActiveModel::ForbiddenAttributeError I do not see how to write a simple test-case for this and for now I reimplemented the #declared(params) helper in my own helpers utilizing a regular Hash. |
@jwkoelewijn @dblock Are |
I would propose to use the standard Hash and add a line or two to the readme to show how one could overwrite the #declared(params) method, for instance by wrapping it in a Hashie::Mash. I would argue that the need for a Mash is not standard, rather an exception. Apart from that, I never felt the need to access parameters as methods.... |
Please see /~https://github.com/Maxim-Filimonov/hashie-forbidden_attributes, what am I missing? |
Ok, so there is a gem to fix a bug introduced by a change to introduce mashes. What's still not entirely clear though is the added value of using this Mash thing in the first place... |
To be fair Mash was used all over the place before Rails4 strong attributes :) But I agree, Mash is "everything to everyone", and possibly there's a better fix that provides Mash semantics by mixing parts of Hashie (indifferent access? method access?) without needing another gem, I would welcome a PR like that. |
Hashie::Mash for declared params