Ruby on rails 禁止属性错误ruby on rails

Ruby on rails 禁止属性错误ruby on rails,ruby-on-rails,ruby,rails-activerecord,omniauth,Ruby On Rails,Ruby,Rails Activerecord,Omniauth,我在Ruby中有这个模型,但它抛出了一个ActiveModel::BankedenAttributeError class User < ActiveRecord::Base def self.from_omniauth(auth) where(auth.slice("uid", "nickname", "image")).first || create_from_omniauth(auth) end def self.create_from_omniauth(auth)

我在Ruby中有这个模型,但它抛出了一个
ActiveModel::BankedenAttributeError

class User < ActiveRecord::Base
def self.from_omniauth(auth)
    where(auth.slice("uid", "nickname", "image")).first ||  create_from_omniauth(auth)
end

def self.create_from_omniauth(auth)
    create! do |user|
        user.uid = auth["uid"]
        user.name = auth["info"]["nickname"]
        user.image = auth["info"]["image"]
    end
  end
end
关于ruby 2.2.1p85(2015-02-26修订版49769)[x86_64-linux]

你能告诉我如何消除这个错误吗


提前感谢。

我认为
切片
方法不再能够绕过强参数。 请尝试以下代码,该代码尝试对身份验证选项更具体:

def self.from_omniauth(auth)
  where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
    user.provider = auth.provider 
    user.uid      = auth.uid
    user.name     = auth.info.name
    user.save
  end
end
您可能需要使用
auth[:provider]
而不是
auth.provider
。 如果这对你有效,请在评论中告诉我。
您也可以浏览帮助我解决问题的内容。

我不知道这是否与此相关。我认为这不是同一个问题。
def self.from_omniauth(auth)
  where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
    user.provider = auth.provider 
    user.uid      = auth.uid
    user.name     = auth.info.name
    user.save
  end
end