Open vad4msiu opened 10 years ago
You're correct. The functionality you describe is the desired. I'll work on it.
Actually I think how it works currently is the desired way. Library users are expected to use strong parameters.
cc @guilleiguaran
@kaspth Why to use strong parameters if you are using form objects? We already list all allowed attributes in attributes
of ActiveForm. Why we need duplicate these attributes in controller?
:+1: I agree with the comment above
I don't mind the duplication concern expressed here as I'm not DRY religious (not saying you are).
To me it feels odd that a form specifies its accepted attributes. Rails moved away from attr_accessible
and this kind of introduces it again. That's part of a controller and why Strong Parameters was added.
On the other hand, specifying attributes
does bring a certain clarity to the form.
What do you think, @m-Peter?
attr_accessible
and attributes in form object it's not the same thing.
I concerned about duplication not because DRY, but because keeping in sync many attributes between form and controller bored.
I share the same opinion with @andrey-skat . I had a hard time trying to setup the nested hierarchy nature that strong_parameters
require.
There is a WIP in this commit: https://github.com/rails/activeform/commit/8e847e7a4206d1e3cb94527e54806e2032cef954 . Let me know your thoughts about it.
@andrey-skat I know they functionally aren't the same, but effectively they are for what we're talking about.
@m-Peter I've left some comments for you on that linked commit.
@kaspth Thanks for your help! I've applied them and will update the commit.
I have form:
Then in a controller I submit params:
But if params contain not
name
key (example:foo
) I have error:NoMethodError: undefined method
foo=' for #. It force my to use
params.slice(...)or
strong_parameters` gem. Why not just ignore attributes which don't defined? I thought form should receive any params but assign only defined?