Jump to content

The ultimate community for Ruby on Rails developers.


Validate field with Devise


  • Please log in to reply
1 reply to this topic

#1 SandyF



  • Members
  • 4 posts

Posted 10 January 2014 - 11:20 PM

I'm trying to set up a beta access key validation and am using Devise for my user registration. 


I've added a field to my user model for the key as input by the registrant, added the key field to my "new" registration form, updated params, etc... All works lovely. 


The next step is that I want to validate that key against a list in a new model that I've named Key and will have our list of allowed keys. 


I'm finding Devise to be a little funky to work with and would appreciate any tips on where I would put the validation code pointing to the Key model. 



#2 stevieing



  • Members
  • 40 posts

Posted 11 January 2014 - 05:02 PM

You can make the key field a drop down list in your registration form and use the allowed keys.


You could also use validates inclusion which will validate against a predetermined list.


If it is required it may be better to have an association for example has_one :key.


Usage of all of the above can be found in the Rails guides http://edgeguides.rubyonrails.org/ which would give you a much better explanation than I could.


Hope that helps



Also tagged with one or more of these keywords: Devise

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users