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.
Does Rails have an upstream sort of method to generate a license agreement checkbox?rails license agreement
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
Now, your creation form should fail, when the user haven't checked the accept terms check box.
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