Ruby on Rails Sunday, June 29, 2014

On Sunday, June 29, 2014 1:19:42 PM UTC+1, Chris Butcher wrote:
> I've just started working on this again after some time off.
>
>
> In response to Fred's suggestion regarding input names, I looked into it and found you can specify custom input names in simple form like this:
>
>
>
>    <span class="impact-input">
>    <%= f.input :impact, required: false, :error => false, input_html: { class: 'form-control', :name => "impact[]" } %>
>    </span>
>    <span class="likelihood-input">
>    <%= f.input :likelihood, required: false, :error => false, input_html: { class: 'form-control', :name => "likelihood[]" } %>
>    </span>
>
>
> Note the ":name => " addition in the input_html attribute.
>
>
> Now this has not fixed the problem at all with regards to app behaviour. However the error message ("unpermitted parameters...")  in terminal has disappeared when I attempt to submit a risk:
>
>
>
>
>
> Started POST "/risks" for 127.0.0.1 at 2014-06-29 12:58:02 +0100
> Processing by RisksController#create as HTML
>   Parameters: {"utf8"=>"✓", "authenticity_token"=>"LOgpMvsEGkhQaoZX5BkrX+Nw1Ov9QQaHuQqWO+L8peI=", "risk"=>{"title"=>"aa", "description"=>"aadad", "area"=>"IT", "owner"=>"5", "action"=>"dadad", "date_of_action(3i)"=>"29", "date_of_action(2i)"=>"6", "date_of_action(1i)"=>"2014", "action_completed"=>"0"}, "impact"=>["4"], "likelihood"=>["4"], "commit"=>"Create Risk"}


You can see here that impact isn't inside the risk hash anymore - you need to set the parameter name to risk[impact][] (and similarly for likelihood).

It's normal that the parameter values are strings - the values from a form submit will always be strings. That shouldn't be a problem.

Fred
>
r.

--
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-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e0ed3251-a4bb-494d-a403-e4d4d31ab5e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment