-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def checked(area) | |
@business_pro.days.nil? ? false : @business_pro.days.match(area) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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