Devise "Creating New Session" is invoking Model's :on => :create validators
I have Devise setup on a Rails Model:
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable
开发者_StackOverflow社区
I also have validation on the same model:
before_validation :geocode_address, :on => :create
When I create new User the geocode_address gets called which is what I want to do but it also gets kicked when the user logs in (creates new Devise Session) which is what I don't want.
Do you know how I can fix that?
This probably happens because the model gets validated on user log in as well. I think that it would be a better idea to utilize after_create on your model, like :
after_create :your_method
def your_method
...
end
Details : http://ar.rubyonrails.org/classes/ActiveRecord/Callbacks.html#M000061
精彩评论