0
我試圖從窗體中的某些複選框獲取值。形式:從複選框獲取值Ruby on Rails,多對多
<%= form_for @book do |f| %>
<%= f.label :title %>
<%= f.text_field :title %>
<%= f.label :description %>
<%= f.text_area :description %>
<% @users.each do |user| %>
<%= check_box_tag 'user_ids[]', user.id,false -%>
<%= h user.name -%>
<% end %>
<%= f.submit "Save" %>
<% end %>
書has_and_belongs_to_many
用戶,所以我想要做的是從複選框中添加user ids
到@book.users
。我怎樣才能做到這一點?我不斷收到錯誤:Can't mass-assign protected attributes: user_ids.