开发者

Devise "Creating New Session" is invoking Model's :on => :create validators

开发者 https://www.devze.com 2023-02-27 10:24 出处:网络
I have Devise setup on a Rails Model: devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable

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

0

精彩评论

暂无评论...
验证码 换一张
取 消