Hello, I''m incorporating a small form that works like a "terms of service agreement", and want to do XYZ if the checkbox is checked. I have this: <%= check_box_tag "user_agreement[]" %> Now, is this the correct way to see if the checkbox is indeed checked: if params[:user_agreement] == true ... end Am I on the right path? Or, is there a better way to do it? -- 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 -~----------~----~----~----~------~----~------~--~---
the params that''s handed back is a string, containing ''0'' or ''1'' (you could modify these values, if necessary) so if params[:user_agreement] == true will fail if params[:user_agreement] will fail the other way around (always true) there are two ways, the simple: if params[:user_agreement] == ''1'' ... end should work. if you store the result in your db, you can use model.user_agreement after saving it or using update_attributes then you would have a ''real'' bool, which would work es expected -- 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the great insight, Thorsten! It looks like storing the result in the db is the best way to do it, and much more efficient than my lousy approach. Thanks a bunch again for the help. -- 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 -~----------~----~----~----~------~----~------~--~---
could you use validates_acceptance_of http://railsmanual.com/module/ActiveRecord::Validations::ClassMethods/validates_acceptance_of or page 366 in Agile Web Development with Rails 2ed. John. On Nov 27, 3:57 am, Bob Sanders <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Thanks for the great insight, Thorsten! > > It looks like storing the result in the db is the best way to do it, and > much more efficient than my lousy approach. Thanks a bunch again for the > help. > -- > Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---