我正在使用自定義集合來顯示具有計劃的複選框。它可以保存,但是當我嘗試編輯時,它會退回給我。爲什麼?編輯模型時未選中「活動管理」複選框
f.inputs for: :schedule, name: 'Employee Schedule' do |sf|
sf.input :sunday, as: :check_boxes, collection: available_hours, method: :to_s
sf.input :monday, as: :check_boxes, collection: available_hours, method: :to_s
sf.input :tuesday, as: :check_boxes, collection: available_hours, method: :to_s
sf.input :wednesday, as: :check_boxes, collection: available_hours, method: :to_s
sf.input :thursday, as: :check_boxes, collection: available_hours, method: :to_s
sf.input :friday, as: :check_boxes, collection: available_hours, method: :to_s
sf.input :saturday, as: :check_boxes, collection: available_hours, method: :to_s
end
def available_hours
(0..23).map { |h| ["#{h}h às #{h.next}h", h] }
end
helper_method :available_hours