ruby-on-rails – Rails 3 http_basic_authenticate_with只在生
发布时间:2020-12-16 20:24:21 所属栏目:百科 来源:网络整理
导读:有没有办法才能使用 http_basic_authenticate_with :name = 'user',:password = 'secret' 当服务器在生产模式下运行时? 解决方法 是的,尝试: class ApplicationController ActionController::Base before_filter :authenticate def authenticate if Rails.
有没有办法才能使用
http_basic_authenticate_with :name => 'user',:password => 'secret' 当服务器在生产模式下运行时? 解决方法
是的,尝试:
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |