我遇到了Omniauth身份验证和Rails 4的问题,由此我得到了Rails ActiveModel :: ForbiddenAttributesError。
我正在使用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
只是为了保持与现有Devise auth系统的兼容性。
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
我不确定这是否相关,但我也一直在运行此错误:
找不到路径“ / auth / mavenlink / callback”的有效映射
也许没有关系,但我认为我会以防万一。
任何帮助将不胜感激!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句