Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 设计Ominauth不会在用户模型中保存电子邮件地址_Ruby On Rails_Facebook_Oauth_Devise - Fatal编程技术网

Ruby on rails 设计Ominauth不会在用户模型中保存电子邮件地址

Ruby on rails 设计Ominauth不会在用户模型中保存电子邮件地址,ruby-on-rails,facebook,oauth,devise,Ruby On Rails,Facebook,Oauth,Devise,我让它工作,但不知怎么的,它现在坏了。几个小时来我一直在为这个头痛。。。我看了Ryan Bates 10倍的视频。一切似乎都是对的。。为什么我不能在用户模型中获取保存电子邮件地址 我在user.rb中有这个 devise :database_authenticatable, :registerable, :omniauthable, :recoverable, :rememberable, :trackable, :validatable, :omniauth_providers =&

我让它工作,但不知怎么的,它现在坏了。几个小时来我一直在为这个头痛。。。我看了Ryan Bates 10倍的视频。一切似乎都是对的。。为什么我不能在用户模型中获取保存电子邮件地址

我在user.rb中有这个

devise :database_authenticatable, :registerable, :omniauthable,
     :recoverable, :rememberable, :trackable, :validatable, :omniauth_providers => [:facebook, :soundcloud]

attr_accessor :email, :password, :password_confirmation, :remember_me, :username, :first_name, :last_name, :city, :country


def self.from_omniauth(auth, current_user)
  where(:provider => auth.provider, :uid => auth.uid.to_s).first_or_create do |user|
  user.provider = auth.provider
  user.uid = auth.uid
  user.username = auth.info.name
  user.avatar = auth.info.image
  user.email = auth.info.email
  user.oauth_token = auth.credentials.token
  user.oauth_secret = auth.credentials.secret
  user.oauth_expires_at = Time.at(auth.credentials.expires_at)
  auth.provider == "soundcloud" ?  user.save(:validate => false) :  user.save
end

结束

因此,现在只需注释attr_accessor行,我就可以保存所有用户数据,包括电子邮件地址。有人想插话解释为什么会这样吗