【发布时间】:2015-01-04 13:25:29
【问题描述】:
我刚刚跟随 this article 在我的 rails 4 应用程序中实现了omniauth。
在我的用户模型中,我有两种类型的用户,即 ADMIN(由表单创建)和 MEMBER(由omniauth 创建)。我需要绕过将由omniauth 创建的会员用户的所有验证。
我知道这可以通过传递这个选项来完成:
save(validate: false)
但是采用了first_or_create方法:
def self.from_omniauth(auth)
# where(auth.slice(:provider, :uid)).first_or_create do |user|
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.email = auth.info.email
user.password = Devise.friendly_token[0,20]
user.name = auth.info.name # assuming the user model has a name
user.image = auth.info.image # assuming the user model has an image
end
end
所以,我的问题是:如何绕过这种omniauth 案例中的所有验证?
请指教。
【问题讨论】:
标签: ruby-on-rails validation ruby-on-rails-4 devise omniauth