2016-07-06 4 views
10

के लिए डेविस नोमेथरर '' मैं एक त्रुटि के साथ पागल हो रहा हूं, जब भी मैं अपने वेब पर गायन/गायन करने की कोशिश करता हूं।पैरामीटर संतिटर

Heroku लॉग्स:

Started GET "https://stackoverflow.com/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 

बात है स्थानीय स्तर पर यह ठीक काम कर रहा है। यह सिर्फ Heroku पर है। और यह कुछ दिनों पहले बस ठीक काम कर रहा था।

+2

इस पर एक नज़र डालें। शायद यह आपकी मदद कर सकता है। http://stackoverflow.com/questions/19791531/how-to-specify-devise-parameter-sanitizer-for-edit-action –

+0

जब आप कहते हैं कि यह ठीक काम कर रहा था तो कुछ दिन पहले आपका मतलब है Heroku? मैं उसकेोकू पर एक नया रत्न प्राप्त करने की कोशिश करता हूं और यह देखने के लिए डायनास को पुनरारंभ करता हूं कि क्या इससे मदद मिलती है। Heroku पर –

+0

मेरी devise मणि 4.2 को अद्यतन किया गया था, इसलिए ".for" अब और काम नहीं कर रहा है। मैं @EddeAlmeida के रूप में इसके बजाय ".permit" में बदल गया है। हालांकि, अब मुझे इसके बारे में अन्य मुद्दे हैं। सबको धन्यवाद। –

उत्तर

36
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 

".for विधि 4.1 +

पहले आर्ग में पदावनत किया गया है कार्रवाई का नाम है:। Sign_up नई वसीयत संसाधनों (जैसे उपयोगकर्ताओं के रूप में) बनाने के लिए है, और: account_update संपादन के लिए है/संसाधन अद्यतन करने

दूसरा आर्ग,:। चाबियाँ मानकों आप की सरणी शामिल

आप nested_attributes चाहते हैं, वहाँ एक उदाहरण में:। account_update, तो आपको एक अलग सरणी में कुंजी किया जा रहा है के साथ डाल दिया _attributes। "