वहाँ एक रास्ता है जब सर्वर उत्पादन मोड पर चल रहा है केवलकेवल रेलवे 3 http_basic_authenticate_with उत्पादन वातावरण में?
http_basic_authenticate_with :name => 'user', :password => 'secret'
उपयोग करने के लिए है?
वहाँ एक रास्ता है जब सर्वर उत्पादन मोड पर चल रहा है केवलकेवल रेलवे 3 http_basic_authenticate_with उत्पादन वातावरण में?
http_basic_authenticate_with :name => 'user', :password => 'secret'
उपयोग करने के लिए है?
authenticate_or_request_with_http_basic do |username, password|
username == "user" && password == "secret"
end if Rails.env.production?
हाँ, कोशिश:
class ApplicationController < ActionController::Base
before_filter :authenticate
def authenticate
if Rails.env.production?
authenticate_or_request_with_http_basic do |username, password|
username == "user" && password == "%$§$§"
end
end
end
end
त्वरित उत्तर के लिए भी धन्यवाद! – Cojones
मैं 'Rails.env.production?" का प्रशंसक नहीं हूं क्योंकि यह सच साबित होता है इससे कोई फर्क नहीं पड़ता कि ऐप किस सर्वर पर चल रहा है। मैं पर्यावरण चर में उपयोगकर्ता नाम/पासवर्ड डालने और सेट करने के आधार पर प्रमाणित करने का निर्णय लेना पसंद करता हूं। लेकिन मुझे एहसास है कि इस सवाल के दायरे से बाहर है। :) – Ricky
बस त्वरित जवाब के लिए
http_basic_authenticate_with :name => 'user', :password => 'secret' if Rails.env.production?
धन्यवाद अपने उदाहरण में जोड़ने! – Cojones