2012-02-22 29 views
7

嘗試我的應用程序從的Rails 3.0遷移到3.2,而隨着這部分我也更新設計的寶石。原來,新設計需要新的OmniAuth寶石。我有Facebook授權配置OmniAuth。在閱讀遷移指南後,我也添加了omniauth-facebook gem並在devise.rb中對其進行了配置。遷移到OmniAuth 1.0:未定義的方法`user_omniauth_authorize_path」

現在,我得到這個錯誤:

ActionView::Template::Error (undefined method `user_omniauth_authorize_path' for #<#:0x00000003b01e88>)

我使用Facebook登錄按鈕,這條道路。我現在應該使用什麼?

用戶模型包含此(user.rb):

# Include default devise modules. Others available are: 
    # :token_authenticatable, :confirmable, :lockable and :timeoutable 
    devise :database_authenticatable, :registerable, 
     :recoverable, :rememberable, :trackable, :validatable, 
     :omniauthable 

全服務器日誌:

Started GET "/" for 127.0.0.1 at 2012-02-22 10:39:27 +0200 
Processing by PagesController#guardian as HTML 
[paperclip] Duplicate URL for photo with /system/:attachment/:id/:style/:filename. This will clash with attachment defined in Asset class 
    Rendered pages/guardian.html.erb within layouts/application (955.6ms) 
Completed 500 Internal Server Error in 1245ms 

ActionView::Template::Error (undefined method `user_omniauth_authorize_path' for #<#<Class:0x00000003b213f0>:0x00000003b01e88>): 
    30:  </p> 
    31:    </td> 
    32:    <td> 
    33:    <%= link_to "Login with Facebook", user_omniauth_authorize_path(:facebook), :class => "login_with_facebook_button" %> 
    34:    </td> 
    35:   </tr> 
    36:  </table> 
     app/views/pages/guardian.html.erb:33:in `_app_views_pages_guardian_html_erb___1979224720320394612_27892940' 

更新:好吧,我設法解決這個問題的路徑。現在當點擊Facebook登錄按鈕,我得到這個:

Started GET "https://stackoverflow.com/users/auth/facebook" for 127.0.0.1 at 2012-02-23 16:02:01 +0200 

NoMethodError (undefined method `include?' for nil:NilClass): 
    omniauth (1.0.2) lib/omniauth/strategy.rb:165:in `call!' 
    omniauth (1.0.2) lib/omniauth/strategy.rb:148:in `call' 
    warden (1.1.1) lib/warden/manager.rb:35:in `block in call' 
    warden (1.1.1) lib/warden/manager.rb:34:in `catch' 
    warden (1.1.1) lib/warden/manager.rb:34:in `call' 

這一切都有點混亂。在我指定了:本教程中提供的:facebook params後,解決了路徑問題:https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview。現在我也注意到我缺少omniauth-facebook wiki中提到的config/initializers文件夾中的omniauth.rb。我創建omniauth.rb包含以下內容,但仍然得到了同樣的問題:

Rails.application.config.middleware.use OmniAuth::Builder do 
    provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'] 
    end 
+0

你能填寫Flash完整的堆棧跟蹤? – shingara 2012-02-22 09:08:46

+0

添加服務器日誌 – 2012-02-22 09:16:14

+0

您是否在用戶模型中添加了omniauthable? – shingara 2012-02-22 11:00:55

回答

5

我,可以這樣設計的發電機解決了這個問題。需要驗證的兩個文件是:config/routes.rb和models/user.rb

在routes.rb文件中,頂部會有一個重複的'devise_for'權限,而user.rb將有默認的設計模塊,因此'omniauthable'需要在這裏添加。

+0

謝謝,會試試這個! – 2012-02-23 09:02:58

+0

你是指這些發電機? '> rails生成模型服務user_id:integer provider:string uid:string uname:string uemail:string > rails generate controller services' – 2012-02-23 10:54:44

+0

我仍然遇到同樣的問題。運行耙路徑也不會列出此路徑。我想知道這條路最初是在哪裏指定的。 – 2012-02-23 13:53:14

4

廣場色器件:omniauthable用戶model.Currently我的版本是 色器件2.0.4,1.1.0 omniauth & omniauth Facebook的1.2.0

+0

完美...你救了我的一天..謝謝 – Dave 2014-08-09 11:38:34

相關問題