Я следил за этим руководством: http://emumair.wordpress.com/2011/03/17/social-network-authentication-with-omniauth-and-authlogic/. Я прошел через все это и получаю такую ошибку:
undefined method `authentications' for #User<User:0x54cd8d8>
Ошибка в контроллере: app / controllers / Authentication_controller.rb: 21: in `create ':
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