Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Does Rails have an upstream sort of method to generate a license agreement checkbox?

rails license agreement

  • Please log in to reply
3 replies to this topic

#1 jschrock1

jschrock1

    Dispatcher

  • Members
  • 45 posts
  • LocationIndianapolis

Posted 25 October 2013 - 05:51 PM

Im almost to the point of taking a few days and digging into the ruby/rails documentation in depth.., but wanted to complete one last entry for my prototype.  I'm still very new to rails and have a simple user signup/signin running, much like the tutorial.  I would like to add a box that contains license verbiage, then a check-box next to it for the user to check before he submits his form..  We've all seen this before.  Im hoping Rails has some method to do this without writing it from scratch.   I even read a post talking about "devices"??  not sure yet what that is, but I'm currently not using that.  Does anyone know if there is some upstream method to help generate this part of the form?  thanks again,   Jay.



#2 Ohm

Ohm

    Guard

  • Members
  • 181 posts
  • LocationCopenhagen

Posted 26 October 2013 - 10:15 AM

You probably mean Devise (https://github.com/p...formatec/devise) which is a gem for authenticating users.

 

What you write about the check box seems fairly simple. Add an accepted_terms field to your User model. Make it a boolean, which defaults to false.

 

After that you can add it to your form and add a validation on the User like so

validates_acceptance_of :accepted_terms

Now, your creation form should fail, when the user haven't checked the accept terms check box.


Blog: http://ohm.sh | Twitter: madsohm


#3 jschrock1

jschrock1

    Dispatcher

  • Members
  • 45 posts
  • LocationIndianapolis

Posted 26 October 2013 - 03:04 PM

That sounds very simple...  thanks you!!



#4 jschrock1

jschrock1

    Dispatcher

  • Members
  • 45 posts
  • LocationIndianapolis

Posted 26 October 2013 - 05:02 PM

Well that actually didn't work..  then I started to read about how validates_acceptance_of only works with virtual attributes, then it occurred to me that I really don't need a persistent column lie "agree_to_terms" in my database, they will never be a users if they don't agree to terms...  So I took it out of the database and then it worked, whoopa! 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users