Skip to content

Instantly share code, notes, and snippets.

@abhianair
Created November 2, 2018 06:55
Show Gist options
  • Save abhianair/3a41ca15edf6b6c542cd50547df3de13 to your computer and use it in GitHub Desktop.
Save abhianair/3a41ca15edf6b6c542cd50547df3de13 to your computer and use it in GitHub Desktop.
Multiple Check Box A probable failed code but can be compiled successfully by perfection
<div class="field">
<%= label_tag 'days_monday', 'Monday' %>
<%= check_box_tag 'business_pro[days][]','Monday',checked('pop'), id: 'days_monday' %>
<%= label_tag 'days_tuesday', 'Tuesday' %>
<%= check_box_tag 'business_pro[days][]','Tuesday',checked('pop'), id: 'days_tuesday' %>
<%= label_tag 'days_wednesday', 'Wednesday' %>
<%= check_box_tag 'business_pro[days][]','Wednesday',checked('pop'), id: 'days_wednesday' %>
</div>
def checked(area)
@business_pro.days.nil? ? false : @business_pro.days.match(area)
end
before_save do
self.days.gsub!(/[\[\]\"]/,"") if attribute_present?("days")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment