嘗試我的應用程序從的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
你能填寫Flash完整的堆棧跟蹤? – shingara 2012-02-22 09:08:46
添加服務器日誌 – 2012-02-22 09:16:14
您是否在用戶模型中添加了omniauthable? – shingara 2012-02-22 11:00:55