how can i whitelist params when used with constantize?

24 views
Skip to first unread message

tom

unread,
Apr 20, 2015, 11:05:07 AM4/20/15
to Ruby on Rails: Talk
x = "SomeClass".classify.constantize.new(params)
>> how can i get the params whitelisted? thank you!

Frederick Cheung

unread,
Apr 21, 2015, 1:59:07 AM4/21/15
to rubyonra...@googlegroups.com
On Monday, April 20, 2015 at 4:05:07 PM UTC+1, der_tom wrote:
> x = "SomeClass".classify.constantize.new(params)>> how can i get the params whitelisted? thank you!

This shouldn't make any difference to how you whitelist the params - what problems are you having?

Fred

tom

unread,
Apr 21, 2015, 10:21:22 AM4/21/15
to Ruby on Rails: Talk
hi
the problem is my update method:
@rec.update(params[:rec].require(@form.sourcetable.singularize.parameterize.underscore.to_sym).permit!)

->

param not found: employer (@rec is the record to be updated)



and here is the params hash:

{"utf8"=>"✓",
 "_method"=>"patch",
 "authenticity_token"=>"GNgGZsqKQgZOcKvGV2pn/sdQ+C/EAqTmQO/bt93cGmo=",
 "rec"=>{"id"=>"3",
 "name"=>"3334",
 "company_id"=>"",
 "created_at"=>"2015-04-21 13:48:17 UTC",
 "updated_at"=>"2015-04-21 13:48:17 UTC",
 "no"=>"",
 "address"=>"",
 "address_2"=>"", .........



--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d8f4cb40-dd27-49a9-bd91-77ad501ff600%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages