मैं प्रमाणीकरण के लिए तैयार कर रहा हूं, हालांकि मैं उपयोगकर्ता को लॉगिन करने की आवश्यकता वाले कार्यों को निर्दिष्ट करने के लिए देख और कार्रवाई फ़िल्टर नहीं कर सकता, क्या यह डिवीज मणि में शामिल है? यदि नहीं, तो मैं एक कैसे बना सकता हूं, मेरे पास एक विचार है लेकिन चूंकि मैं रेल के लिए नया हूं, इसलिए मैं पहले एक अनुभवी प्रोग्रामर से समाधान ढूंढूंगा।प्रमाणीकरण की आवश्यकता वाले कार्यों के लिए डिवाइज़ एक्शन फ़िल्टर
11
A
उत्तर
23
Devise Readme देखें।
class PostsController < ApplicationController
respond_to :html
# Tell Devise that the #destroy action is
# special, and that the user must be
# authenticated in order to access the
# #desroy action.
# Note that the name of the method here,
# #authenticate_user!, depends on the
# particular class/table that you have
# set up to be managed with Devise.
before_filter :authenticate_user!,
:only => [:destroy]
before_filter :find_post!,
:only => [:destroy]
def destroy
@post.destroy
respond_with @post
end
private
def find_post!
@post = Post.find(params[:id])
end
end
0
अन्य समाधान उदाहरण के लिए उपयोग करने के लिए है: को छोड़कर => लॉगिन, अपने का उपयोग करते समय पूरे एप्लिकेशन के उपयोग प्रमाणीकरण और आप सार्वजनिक उपयोग के साथ एक पृष्ठ करना चाहते हैं