0
好這個問題我確定它並不難,但是對於rails來說我是新手,我有點迷路。 在觀看Railscasts第52集後,我繼續製作自己的發佈/未發佈幻燈片列表。帶複選框的多更新布爾狀態(Rails 3)
所以這是表單視圖
= form_tag publish_admin_category_slides_path(@cat4), :method => "put" do
#pricing
%table#plans
%thead
%tr
%th Image
%th Published
%tbody
- @image.each do |im|
%tr.odd
%td
= image_tag im.avatar.url(:thumb)
= link_to "Delete", admin_category_slide_path(@cat4,im), :method => "delete"
%span is
%th
= check_box_tag "slide_published[]", im.published ,im.published
隨着控制器動作#publish
def publish
Slide.update_all(:published => params[:slide_published])
redirect_to :action => "index"
end
什麼會寫這樣的事情的正確方法? 帶有複選框的列表改變了屬性和多重更新的布爾狀態?