I'm using devise for user authentication. However, when a user tries to create an account I am getting this error:
我正在使用设计进行用户身份验证。但是,当用户尝试创建帐户时,我收到此错误:
NameError (undefined local variable or method `devise_parameter_sanitizer'
This is what my devise registrations controller looks like:
这就是我的设计注册控制器的样子:
def sign_up_params
devise_parameter_sanitizer.for(:sign_up)
end
Any ideas?
有任何想法吗?
Thanks in advance
提前致谢
4 个解决方案
#1
6
try to use rails4 branch
尝试使用rails4分支
gem 'devise', github: 'plataformatec/devise', branch: 'rails4'
#2
3
Looking at the devise open issues on Github i found this: https://github.com/plataformatec/devise/issues/2372 - seem to do the trick for me. note that this is probably a rails 4 issue.
看看Github上的设计开放问题我发现了这个:https://github.com/plataformatec/devise/issues/2372 - 似乎对我有用。请注意,这可能是一个rails 4问题。
#3
2
For anyone who ends up here with error
对于任何最终错误的人
undefined method `<<' for {}:ActionController::Parameters
you need to upgrade to Devise 3.1.0.rc as in this comment
which basically means using master branch version
你需要升级到Devise 3.1.0.rc,就像在这个评论中一样,这基本上意味着使用master分支版本
gem 'devise', git: 'git://github.com/plataformatec/devise.git'
hope I help some lost souls as I was for last half an hour.
希望我像过去半小时那样帮助一些失去的灵魂。
#4
1
The latest released Gem for Devise at the time of writing is 2.2.4. This does not include the devise_parameter_sanitizer
method, hence the error you are seeing.
在撰写本文时,最新发布的Gem for Devise是2.2.4。这不包括devise_parameter_sanitizer方法,因此您会看到错误。
You are probably following the manual for Devise at https://github.com/plataformatec/devise. The section on Rails 4 and Strong Parameters has been added recently.
您可能正在访问设计手册,网址为https://github.com/plataformatec/devise。最近添加了关于Rails 4和Strong Parameters的部分。
You have a few options:
你有几个选择:
-
Get the latest master version of Devise using bundler, so that the
devise_parameter_sanitizer
method is available:使用bundler获取最新的Devise主版本,以便devise_parameter_sanitizer方法可用:
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'
gem'depaise',:git =>'git://github.com/plataformatec/devise.git'
-
Don't apply
ActiveModel::ForbiddenAttributesProtection
to your User model, so strong parameters are not even used. More info here: Devise and Strong Parameters不要将ActiveModel :: ForbiddenAttributesProtection应用于您的用户模型,因此甚至不使用强参数。更多信息:设计和强参数
-
Override the required Devise controllers directly. See here: https://gist.github.com/kazpsp/3350730
直接覆盖所需的Devise控制器。见这里:https://gist.github.com/kazpsp/3350730
#1
6
try to use rails4 branch
尝试使用rails4分支
gem 'devise', github: 'plataformatec/devise', branch: 'rails4'
#2
3
Looking at the devise open issues on Github i found this: https://github.com/plataformatec/devise/issues/2372 - seem to do the trick for me. note that this is probably a rails 4 issue.
看看Github上的设计开放问题我发现了这个:https://github.com/plataformatec/devise/issues/2372 - 似乎对我有用。请注意,这可能是一个rails 4问题。
#3
2
For anyone who ends up here with error
对于任何最终错误的人
undefined method `<<' for {}:ActionController::Parameters
you need to upgrade to Devise 3.1.0.rc as in this comment
which basically means using master branch version
你需要升级到Devise 3.1.0.rc,就像在这个评论中一样,这基本上意味着使用master分支版本
gem 'devise', git: 'git://github.com/plataformatec/devise.git'
hope I help some lost souls as I was for last half an hour.
希望我像过去半小时那样帮助一些失去的灵魂。
#4
1
The latest released Gem for Devise at the time of writing is 2.2.4. This does not include the devise_parameter_sanitizer
method, hence the error you are seeing.
在撰写本文时,最新发布的Gem for Devise是2.2.4。这不包括devise_parameter_sanitizer方法,因此您会看到错误。
You are probably following the manual for Devise at https://github.com/plataformatec/devise. The section on Rails 4 and Strong Parameters has been added recently.
您可能正在访问设计手册,网址为https://github.com/plataformatec/devise。最近添加了关于Rails 4和Strong Parameters的部分。
You have a few options:
你有几个选择:
-
Get the latest master version of Devise using bundler, so that the
devise_parameter_sanitizer
method is available:使用bundler获取最新的Devise主版本,以便devise_parameter_sanitizer方法可用:
gem 'devise', :git => 'git://github.com/plataformatec/devise.git'
gem'depaise',:git =>'git://github.com/plataformatec/devise.git'
-
Don't apply
ActiveModel::ForbiddenAttributesProtection
to your User model, so strong parameters are not even used. More info here: Devise and Strong Parameters不要将ActiveModel :: ForbiddenAttributesProtection应用于您的用户模型,因此甚至不使用强参数。更多信息:设计和强参数
-
Override the required Devise controllers directly. See here: https://gist.github.com/kazpsp/3350730
直接覆盖所需的Devise控制器。见这里:https://gist.github.com/kazpsp/3350730