Rails 3 http_basic_authenticate_with только в производственной среде?
есть ли способ использовать
http_basic_authenticate_with :name => 'user', :password => 'secret'
когда сервер работает в рабочем режиме?
Ответы
Ответ 1
Да, попробуйте:
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
Ответ 2
Просто добавьте это в свой пример
http_basic_authenticate_with :name => 'user', :password => 'secret' if Rails.env.production?
Ответ 3
authenticate_or_request_with_http_basic do |username, password|
username == "user" && password == "secret"
end if Rails.env.production?