0
我一直在關注本教程:http://emumair.wordpress.com/2011/03/17/social-network-authentication-with-omniauth-and-authlogic/。我通過這一切走了,我得到這個錯誤:omniauth與身份驗證方法authlogic問題
undefined method `authentications' for #User<User:0x54cd8d8>
其未能在控制器中:應用程序/控制器/ authentications_controller.rb:21:在'創造':
user.authentications.build(:provider => omniauth['provider'], :uid => omniauth['uid'])
我是否需要爲用戶模型添加認證的關係?
我的用戶模型目前看起來是這樣的:
class User < ActiveRecord::Base
acts_as_authentic
def apply_omniauth(omniauth)
self.email = omniauth['user_info']['email']
# Update user info fetching from social network
case omniauth['provider']
when 'facebook'
# fetch extra user info from facebook
when 'twitter'
# fetch extra user info from twitter
end
end
end
我authentication.rb文件是:
class Authentication < ActiveRecord::Base
belongs_to :user
validates :user_id, :uid, :provider, :presence => true
validates_uniqueness_of :uid, :scope => :provider
end
是否需要運行遷移來創建身份驗證表? – 2012-03-18 19:07:17
是的,我創建了教程中顯示的遷移並運行它。 – turbo2oh 2012-03-18 19:09:20