2011-08-26 40 views
0

我有一個註冊機制,通過確認鏈接激活後完成。現在我想刪除可確認的,我希望用戶在註冊後直接登錄。請告訴我需要做些什麼改變,我該如何做?我是否也需要從數據庫中刪除確認字段?請告訴我整個過程。註冊並直接登錄軌道3設計?

回答

0

在將用戶保存到db之前,您需要使用@user.skip_confirmation!。 如果你使用的是registration_controller,那麼@user對象就像資源一樣。

這是registrations_controller的創建方法。

def create 
    build_resource 
    resource.skip_confirmation! 
    if resource.save 
     if resource.active_for_authentication? 
     set_flash_message :notice, :signed_up if is_navigational_format? 
     sign_in(resource_name, resource) 
     respond_with resource, :location => redirect_location(resource_name, resource) 
     else 
     set_flash_message :notice, :inactive_signed_up, :reason => inactive_reason(resource) if is_navigational_format? 
     expire_session_data_after_sign_in! 
     respond_with resource, :location => after_inactive_sign_up_path_for(resource) 
     end 
    else 
     clean_up_passwords(resource) 
     respond_with_navigational(resource) { render_with_scope :new } 
    end 
    end 
+0

它的工作原理,但我不想因爲我不是凍結在registeration的控制人變更設計寶石,是否有任何其他方式,以便我可以從我的應用程序中刪除可確認? –

+0

其他可能的解決方案是:你可以從user.rb模型中刪除可確認的。然後刪除數據庫 - 創建數據庫 - 然後遷移和C無論代碼工作與否... –

0

只需從用戶模型中刪除可確認的模塊。

devise :confirmable, … 
+0

以及我已經做了這一點,但它不工作,即使是現在我的註冊頁面未簽約..... –