我正在关注这个:教程
user = User.new :name => auth_hash["user_info"]["name"], :email => auth_hash["user_info"]["email"]
user.authorizations.build :provider => auth_hash["provider"], :uid => auth_hash["uid"]
user.save
render :text => "Hi #{user.name}! You've signed up."
我正在浏览数据库并检查表authorization
,发现表是空的。
这是为什么?
编辑: 我收到此错误:
糟糕,出了点问题:[“授权无效”]
这是用户.rb:
class User < ActiveRecord::Base
has_many :topics
has_many :authorizations
attr_accessible :email, :name
validates :name, :email, :presence => true
end
这是授权.rb:
class Authorization < ActiveRecord::Base
belongs_to :user
validates :provider, :uid, :presence => true
attr_accessible :provider, :uid
end