我正在与Omniauth认证的问题和轨道4由此我得到一个Rails ::加载ActiveModel ForbiddenAttributesError。加载ActiveModel的Rails :: ForbiddenAttributesError设计,Omniauth
我使用gem 'protected_attributes'
如此强大的参数不应该是一个问题。
我的用户模型包含以下内容:
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_create do |user|
user.username = auth.info.email
user.email = auth.info.email
user.password = Devise.friendly_token[0,20]
user.name = auth.info.name
end
end
user.password
在那里只是为了保持与现有设计身份验证系统的兼容性。
的AR错误表明该行:where(auth.slice(:provider, :uid)).first_or_create do |user|
抛出的错误。
上述方法被调用来自:
class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def mavenlink
@user = User.from_omniauth(request.env['omniauth.auth'])
service = @user.services.initialize_or_update_via_omniauth(request.env['omniauth.auth'])
if service && service.save
sign_in_and_redirect @user #this will throw if @user is not activated
set_flash_message(:notice, :success, :kind => "Mavenlink") if is_navigational_format?
else
redirect_to root_path, error: "Error signing in with Mavenlink credentials."
end
end
end
这是否与或没有,我不知道,但我也一直在运行此错误:
找不到有效的为路径映射“/认证/ mavenlink /回调”
也许没有关系,但我想我有以防万一。
任何帮助将不胜感激!
把上面一行'那里(服务提供商:auth.provider,UID:auth.uid).first_or_create做|用户|'。这应该够了吧。 – 2015-02-07 20:08:58
这样做,谢谢!为什么是这个问题? – Adam 2015-02-07 20:17:25
[Rails 4.1.5 omniauth strong parameters]可能重复(http://stackoverflow.com/questions/25399414/rails-4-1-5-omniauth-strong-parameters) – zhurora 2015-09-10 13:39:27