I changed the hidden field to f.hidden_field but kept getting errors if I 
tried to change the checkbox as well. In reading some of the answers for 
the error it kept using the check_box_tag to get it to work. Good call out 
on repeating my event selected. Doesn't hurt but doesn't make sense either! 

On Wednesday, October 14, 2015 at 7:19:36 AM UTC-5, Frederick Cheung wrote:
>
>
>
> On Tuesday, October 13, 2015 at 9:46:28 PM UTC+1, Prkl8r wrote:
>>
>>
>> def invite_params
>> params.require(:attended_event_id => params[:event_selected], :attendee_id 
>> => params[:user_ids].first )
>>  end
>>
>>
> This is completely wrong. This usually looks something like
>
> params.require(:invitation).permit(:attended_event_id, :attendee_id)
>
> which says that the params hash should contain an element for the key 
> :invitation, and that the two named parameters are allowed to be present. 
> (A more elaborate syntax allows for array and hash values - lookup the docs 
> for 'strong parameters')
>  
>
>>
>> My view showing the list of users and after selecting a checkbox, should 
>> pass the event_selected and user_ids.
>>
>>
>> invitations/new.html.erb
>>
>>     <h3>Invite users to <%= @event_selected.name %></h3>
>> <%= bootstrap_form_for Invitation.new do |f| %><br>
>>   <ul>
>>     <% @users.each do |user| %>
>>     <li>
>>       <%= hidden_field_tag :event_selected, @event_selected.id %>
>>   <%= check_box_tag 'user_ids[]', user.id %>
>>   <%= h user.name %>
>>   
>>
> When you use the _tag helpers (as opposed to g.hidden_field, f.check_box), 
> then your parameters aren't nested with invitation hash as mentioned above. 
> You'll also make your life much easier if the input names correspond to the 
> model attribute names (i.e. attended_event_id instead of event_selected). 
> It also seems a bit odd (although probably harmless) that you are repeating 
> the event_selected input.
>
> Fred 
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/6f8e3e48-6be5-461b-a208-1c347489703f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to