Cassio Cabral
Cassio Cabral

Reputation: 2682

Rails 4 form with namespace generates undesired params

I have this on my form

= simple_form_for polymorphic_path([:admin, @place]), :url => admin_places_path(@place), :method => 'post' ...



Parameters: {"utf8"=>"✓","authenticity_token"=>"UzvU072fWHiuSDD0BsIEaLqmIKJWujiFzWval8MripU=", "/admin/places"=>{"name"=>"My Name", "description"=>"My Description"}, "commit"=>"Ok"

Unpermitted parameters: utf8, authenticity_token, /admin/places, commit

What I want is the param "/admin/places" become "place" and that way my params.require(:place).permit(...) work. I think that way looks better and was wondering how to achieve it.

Upvotes: 0

Views: 462

Answers (1)

Cassio Cabral
Cassio Cabral

Reputation: 2682

I removed the polymorphic_path to @place only. simple_form_for(as form_for) expected a object that represent the Place itself. Now using the params.require(:place)... works

Upvotes: 0

Related Questions