Override authlogic's email validation
I am开发者_如何学Python making a login using AuthLogic, but I would like 'email' to be optional. It seems however that authlogic out of the box makes this validated for. Anyone know a workaround?
from the authlogic example rails application:
- Set up your model
Make sure you have a model that you will be authenticating with. Since we are using the User model it should look something like:
class User < ActiveRecord::Base acts_as_authentic do |c| c.my_config_option = my_value # for available options see documentation in: Authlogic::ActsAsAuthentic end # block optional end
One thing to note here is that this tries to take care of all the authentication grunt work, including validating your login, email, password, and token fields. You can easily disable this with configuration. Ex: c.validate_email_field = false. See the Authlogic::ActsAsAuthentic sub modules in the documentation for more details.
Key part to note:
You can easily disable this with configuration. Ex: c.validate_email_field = false.
Hope that helps.
Source: https://github.com/binarylogic/authlogic_example
While searching my contents ..i found out http://rdoc.info/github/binarylogic/authlogic/master/Authlogic/ActsAsAuthentic/Email/Config#merge_validates_format_of_email_field_options-instance_method this will surely help..
精彩评论