मेरे पास एक रेल आवेदन है जिसे मैं रेल 5 में अपग्रेड करने की योजना बना रहा हूं। मैं रेल (v5.0.0) के साथ devise (v4.2.0) का उपयोग कर रहा हूं। के रूप में चिंतन करना README.md फ़ाइल में सुझाव दिया है, मैं before_filter ऊपर protect_from_forgery लेकिन अभी भी बढ़ रहा है जब मैं के लिए लॉग इन या मेरे बग अद्यतन मैं कोई त्रुटि मिलती है ActionController::InvalidAuthenticityToken
रेल 5 एक्शन कंट्रोलर :: अमान्य प्रमाणीकरण टोकन त्रुटि
मेरे Application Controller
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception, prepend: true
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
devise_parameter_sanitizer.permit(:account_update, keys: [:name])
end
end
और है करने के लिए कोशिश कर रहा हूँ की कोशिश की मेरी अन्य BugController
class BugsController < ApplicationController
protect_from_forgery prepend: true, with: :exception
before_action :authenticate_user!
before_action :set_bug, only: [:show, :edit, :update]
def update
respond_to do |format|
if @bug.update(bug_params)
format.html { redirect_to @bug, notice: 'Bug was successfully updated.' }
format.json { render :show, status: :ok, location: @bug }
else
format.html { render :edit }
format.json { render json: @bug.errors, status: :unprocessable_entity }
end
end
end
private
def bug_params
params.require(:bug).permit(:product, :component, :title, :description, :status_id, :created_by_id, :assigned_to_id)
end
end
देखें कि मैंने 'skip_before_filter: verify_authenticity_token' को बग नियंत्रक में डालने का प्रयास किया लेकिन अभी भी काम नहीं करता है। – HSD
मुझे दिखाएं कि आपने इसे कहां रखा है – Boltz0r
'बग्स कंट्रोलर' 'protect_from_forgery प्रीपेन्ड में: सत्य, इसके साथ:: अपवाद पहले_एक्शन: प्रमाणीकरण_यूसर! before_action: set_bug, केवल: [: शो,: संपादित करें,: अद्यतन] ' – HSD