My app has a Permission
model and permissions
table with an email
field. Existing users (User
model) can add the email addresses of people who they would like to invite to view their information. Those email addresses are stored in the permissions.email
field in the database.
How do I go about modifying Devise's registration process so that it only allows people with an email address in the permissions
table to create an account?
did this before with a validator on the user model; e.g.
validates :email, :my_access_control => true
and then create something like this
class MyAccessControlValidator < ActiveModel::EachValidator
def validate_each(object, attribute, value)
if ... not in permissions table..
... add to objects error collection why they cannot register
end
end
end