I have form:
class Forms::Publishers::CreateForm < ActiveForm::Base
attributes :name
validates :name, presence: true
end
Then in a controller I submit params:
form = Forms::Publishers::CreateForm.new(publisher)
form.submit(params)
But if params contain not name key (example: foo) I have error: NoMethodError: undefined method foo=' for #Forms::Publishers::CreateForm:0x007f85805f70a0. It force my to use params.slice(...)orstrong_parameters` gem. Why not just ignore attributes which don't defined? I thought form should receive any params but assign only defined?
I have form:
Then in a controller I submit params:
But if params contain not
namekey (example:foo) I have error:NoMethodError: undefined methodfoo=' for #Forms::Publishers::CreateForm:0x007f85805f70a0. It force my to useparams.slice(...)orstrong_parameters` gem. Why not just ignore attributes which don't defined? I thought form should receive any params but assign only defined?