Rails ActiveModel :: ForbiddenAttributesError设计,Omniauth

亚当

我遇到了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”的有效映射

也许没有关系,但我认为我会以防万一。

任何帮助将不胜感激!

贾斯汀

几周前我遇到了同样的问题,并通过更改下面的行来解决。本质上,您应该将参数显式传递到查询中。

where(provider: auth.provider, uid: auth.uid).first_or_create do |user|

您可以找到有关此问题设计问题

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Rails ActiveModel :: ForbiddenAttributesError

来自分类Dev

rails 4 ActiveModel :: ForbiddenAttributesError

来自分类Dev

ActiveModel :: ForbiddenAttributesError Ruby on Rails

来自分类Dev

ActiveModel :: ForbiddenAttributesError Rails 4.1

来自分类Dev

Rails 4和Active Admin:ActiveModel :: ForbiddenAttributesError

来自分类Dev

Rails 4强参数ActiveModel :: ForbiddenAttributesError

来自分类Dev

Rails 4强参数ActiveModel :: ForbiddenAttributesError

来自分类Dev

Rails 4和Active Admin:ActiveModel :: ForbiddenAttributesError

来自分类Dev

Rspec-rails 4错误:ActiveModel :: ForbiddenAttributesError

来自分类Dev

ActiveModel :: ForbiddenAttributesError

来自分类Dev

ActiveModel :: ForbiddenAttributesError在使用设计进行注册时

来自分类Dev

ActiveModel :: ForbiddenAttributesError为什么Rails会忽略Strong_params?

来自分类Dev

ruby on rails-CommentsController#create中的ActiveModel :: ForbiddenAttributesError

来自分类Dev

ActiveModel::ForbiddenAttributesError in comments controller

来自分类Dev

Rails设计专家omniauth

来自分类Dev

ActiveModel :: ForbiddenAttributesError + cancan + rails 4 +具有范围控制器的模型

来自分类Dev

在Rails 5演示应用程序上,在ArticlesController#create中获取ActiveModel :: ForbiddenAttributesError

来自分类Dev

rails 4 ActiveModel::ForbiddenAttributesError 属性作为变量失败,属性说明成功

来自分类Dev

参数错误(ActiveModel :: ForbiddenAttributesError)

来自分类Dev

Rails 5 中的 ActiveModel::UnknownAttributeError

来自分类Dev

Rails ActiveModel使用单个类设计belongs_to和has_many

来自分类Dev

Assign_attributes和ActiveModel :: ForbiddenAttributesError

来自分类Dev

CommentsController#create中的错误:ActiveModel :: ForbiddenAttributesError

来自分类常见问题

创建新用户时ActiveModel :: ForbiddenAttributesError

来自分类Dev

注释控制器中的ActiveModel :: ForbiddenAttributesError

来自分类Dev

在控制器中获取ActiveModel :: ForbiddenAttributesError

来自分类Dev

CommentsController#create中的ActiveModel :: ForbiddenAttributesError

来自分类Dev

无法从ActiveAdmin界面更新资源-ActiveModel :: ForbiddenAttributesError

来自分类Dev

PostsController#create中的ActiveModel :: ForbiddenAttributesError

Related 相关文章

  1. 1

    Rails ActiveModel :: ForbiddenAttributesError

  2. 2

    rails 4 ActiveModel :: ForbiddenAttributesError

  3. 3

    ActiveModel :: ForbiddenAttributesError Ruby on Rails

  4. 4

    ActiveModel :: ForbiddenAttributesError Rails 4.1

  5. 5

    Rails 4和Active Admin:ActiveModel :: ForbiddenAttributesError

  6. 6

    Rails 4强参数ActiveModel :: ForbiddenAttributesError

  7. 7

    Rails 4强参数ActiveModel :: ForbiddenAttributesError

  8. 8

    Rails 4和Active Admin:ActiveModel :: ForbiddenAttributesError

  9. 9

    Rspec-rails 4错误:ActiveModel :: ForbiddenAttributesError

  10. 10

    ActiveModel :: ForbiddenAttributesError

  11. 11

    ActiveModel :: ForbiddenAttributesError在使用设计进行注册时

  12. 12

    ActiveModel :: ForbiddenAttributesError为什么Rails会忽略Strong_params?

  13. 13

    ruby on rails-CommentsController#create中的ActiveModel :: ForbiddenAttributesError

  14. 14

    ActiveModel::ForbiddenAttributesError in comments controller

  15. 15

    Rails设计专家omniauth

  16. 16

    ActiveModel :: ForbiddenAttributesError + cancan + rails 4 +具有范围控制器的模型

  17. 17

    在Rails 5演示应用程序上,在ArticlesController#create中获取ActiveModel :: ForbiddenAttributesError

  18. 18

    rails 4 ActiveModel::ForbiddenAttributesError 属性作为变量失败,属性说明成功

  19. 19

    参数错误(ActiveModel :: ForbiddenAttributesError)

  20. 20

    Rails 5 中的 ActiveModel::UnknownAttributeError

  21. 21

    Rails ActiveModel使用单个类设计belongs_to和has_many

  22. 22

    Assign_attributes和ActiveModel :: ForbiddenAttributesError

  23. 23

    CommentsController#create中的错误:ActiveModel :: ForbiddenAttributesError

  24. 24

    创建新用户时ActiveModel :: ForbiddenAttributesError

  25. 25

    注释控制器中的ActiveModel :: ForbiddenAttributesError

  26. 26

    在控制器中获取ActiveModel :: ForbiddenAttributesError

  27. 27

    CommentsController#create中的ActiveModel :: ForbiddenAttributesError

  28. 28

    无法从ActiveAdmin界面更新资源-ActiveModel :: ForbiddenAttributesError

  29. 29

    PostsController#create中的ActiveModel :: ForbiddenAttributesError

热门标签

归档