Ứng dụng của tôi được thiết lập để nếu người dùng đăng nhập bằng Oauth hoặc Openid, họ không phải xác nhận địa chỉ email của họ. Tuy nhiên, Devise vẫn đang gửi xác nhận qua email. Khi tôi gọi User.skip_confirmation! Tôi gặp lỗi phương thức không xác định. Mô hình của tôi:Devise skip_confirmation! không hoạt động
class User < ActiveRecord::Base
devise :database_authenticatable, :registerable, :recoverable, :rememberable,
:trackable, :validatable, :confirmable, :lockable, :token_authenticatable, :omniauthable
attr_accessible :username, :email, :password, :password_confirmation, :remember_me
validates_presence_of :username
validates_uniqueness_of :username, :case_sensitive => false
def self.find_for_facebook_oauth(access_token, signed_in_resource=nil)
data = access_token.extra.raw_info
if user = User.where(:email => data.email).first
user
else
#User.skip_confirmation!
User.create!(:username => data.name, :email => data.email, :password => Devise.friendly_token[0,20])
end
end
def skip_confirmation!
self.confirmed_at = Time.now
end
end
điều khiển của tôi:
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
def facebook
@user = User.find_for_facebook_oauth(request.env["omniauth.auth"], current_user)
@user.skip_confirmation!
if @user.persisted?
sign_in @user
@fname = @user.username
redirect_to root_path, :flash => { :success => "Welcome #{@fname}!" }
else
session["devise.facebook_data"] = request.env["omniauth.auth"]
redirect_to new_user_registration_url
end
end
end
nhờ sự giúp đỡ nào.
Vì bạn đang sử dụng: confirmable bạn không thực sự cần thông báo 'skip_confirmation! '(http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable#skip_confirmation%21-instance_method) Bạn có thể đăng stack-trace không? Tôi nghi ngờ đó là phương thức 'skip_confirmation!' Bị thiếu. – Tigraine