为“ParameterSanitizer”设计NoMethodError' [英] Devise NoMethodError 'for' ParameterSanitizer
问题描述
Heroku日志:
我正在努力尝试在我的网路上唱歌> 开始GET/ users / sign_in为201.235.89.150在20167-06 01:35:03 +0000
完成500内部服务器错误(ActiveRecord:0.0ms)
NoMethodError(未定义方法`for'for#< Devise :: ParameterSanitizer:0x007f5968e0a920>):
app / controllers / application_controller.rb:11 :在`configure_permitted_parameters'
application_controller.rb
class ApplicationController< ActionController :: Base
#通过引发异常来防止CSRF攻击。
#对于API,您可能需要使用:null_session。
protect_from_forgery with::exception
before_filter:configure_permitted_parameters,如果::devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up){| u | u.permit(:username,:email,:password,:provider,:uid)}
devise_parameter_sanitizer.for(:account_update){| u | u.permit(:username,:email,:password,:current_password)}
end
end
事情是在本地工作正常。只是在Heroku。还有几天前工作正常。
class ApplicationController< ; ActionController :: Base
before_action:configure_permitted_parameters,如果::devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up,keys:[:first_name,:last_name,:email])
devise_parameter_sanitizer.permit (:account_update,keys:[:first_name,:last_name,:phone,:email,bank_attributes:[:bank_name,,bank_account]])
end
end
.for方法已在4.1 +
中弃用第一个参数是动作名称:sign_up用于创建新的Devise资源(如用户),并且:account_update用于编辑/更新资源。
第二个参数:您可以使用的参数数组。
如果要使用nested_attributes,则有一个示例:account_update,您将一个单独的数组放在其中,该键是_attributes。
I'm going nuts with an error I'm getting every time I try to sing in/sing up on my web.
Heroku logs:
Started GET "/users/sign_in" for 201.235.89.150 at 2016-07-06 01:35:03 +0000
Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.0ms)
NoMethodError (undefined method `for' for #<Devise::ParameterSanitizer:0x007f5968e0a920>):
app/controllers/application_controller.rb:11:in `configure_permitted_parameters'
application_controller.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:username, :email, :password, :provider, :uid) }
devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :current_password) }
end
end
The thing is it is working fine locally. It´s just on Heroku. And also it was working just fine a couple of days ago.
class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name, :last_name, :email])
devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name, :phone, :email, bank_attributes: [:bank_name, :bank_account]])
end
end
"The .for method is deprecated in 4.1 +
The first arg is the action name. :sign_up is for creating new Devise resources (such as users), and :account_update is for editing/updating the resource.
The second arg, :keys contains an array of the parameters you allow.
If you want nested_attributes, there is an example in :account_update, you put a separate array in with the key being _attributes."
这篇关于为“ParameterSanitizer”设计NoMethodError'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!