2011-12-29 13 views
10

मेरा ऐप सेट अप किया गया है ताकि यदि कोई उपयोगकर्ता ओथ या ओपनिड के साथ साइन इन करता है, तो उन्हें अपने ईमेल पते की पुष्टि करने की आवश्यकता नहीं है। हालांकि, डेविस अभी भी ईमेल पुष्टिकरण भेज रहा है। जब मैं User.skip_confirmation को कॉल करता हूं! मुझे एक अपरिभाषित विधि त्रुटि मिलती है। मेरे मॉडल:डेविस skip_confirmation! काम नहीं कर रहा

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 

मेरे नियंत्रक: किसी भी मदद के लिए

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 

धन्यवाद।

+0

के बाद से आप पहले से ही उपयोग कर रहे हैं: confirmable आप वास्तव में 'skip_confirmation!' संदेश की आवश्यकता नहीं है (http://rubydoc.info/github/plataformatec/devise/master/Devise/Models/Confirmable#skip_confirmation%21-instance_method) क्या आप स्टैक-ट्रेस पोस्ट कर सकते हैं? मुझे संदेह है कि यह 'skip_confirmation!' विधि है जो गुम है। – Tigraine

उत्तर

35

उपयोगकर्ता ऑब्जेक्ट्स बनाने और डेटाबेस के लिए बने रहने से पहले आपको पुष्टि छोड़ने की आवश्यकता है। तो अपने विधि के उपयोगकर्ता निर्माण भाग की तरह

 
user = User.new(:username => data.name, :email => data.email, :password => Devise.friendly_token[0,20]) 
user.skip_confirmation! 
user.save 
+0

मैंने user.screate में user.save को बदलने के बाद काम किया। धन्यवाद। –

+0

मुझे लगता है कि आपको 'उपयोगकर्ता' को अंतिम पंक्ति के रूप में जोड़ने की भी आवश्यकता है, इसलिए यह – kambi

+0

हाय रिश्व के रिटर्न वैल्यू रहेगा, मेरे पास user.rb में बिल्कुल वही कोड है, फिर भी मेरा ऐप पुष्टि ईमेल भेजता है जब भी मैं इसे फेसबुक में अधिकृत करें। कोई विचार क्यों user.skip_confirmation! कुछ नहीं कर रहा है? –

7

लगेगा यदि आप एक उपयोगकर्ता रिकॉर्ड को अपडेट कर रहे हैं, तो skip_reconfirmation! का उपयोग सुनिश्चित करें (मन फिर)

संबंधित मुद्दे