hi, i am trying to use one check_box with instance variable and trying to get true or false value from database table. and also please give me solution for multiple check_box and select all how to feed and retrieve value and show in check box. Thanks Purab -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Something like this for your first two questions? <% POSSIBLE_CATEGORIES.each do |web|%> <% if option_checked(web) %> <%= check_box_tag web, ''1'', true%><%= web %><% else %> <%= check_box_tag web %><%= web %><% end%> <% end %> Where POSSIBLE_CATEGORIES is an array of what you want the check boxes to represent, ''1'' is the value of a checked check box, and true defaults it to checked. option_checked(web) is a method in ApplicationHelper that compares the name of the check box (gotten from POSSIBLE_CATEGORIES) to something stored in the database. You could easily modify it for the true/false that you want. Sorry if I misunderstand/this doesn''t solve your problem (and there''s probably a better way to do this, but this works for me). -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, Jun 18, 2008 at 4:12 PM, Purab Kharat <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> i am trying to use one check_box with instance variable and trying to > get true or false value from database table. > > and also please give me solution for multiple check_box and select all > > how to feed and retrieve value and show in check box.Have a look at the check_box helper. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---