Ruby on Rails BASIC認証
Ruby on RailsでBASIC認証をかけるには、
authenticate_or_request_with_http_basicを使用します。
app/controllers/application_controller.rb
※「ユーザー名」、「パスワード」の部分は適切に設定してください。
authenticate_or_request_with_http_basicを使用します。
app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
before_filter :authenticate
private
def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == 'ユーザー名' && password == 'パスワード'
end
end
end
※「ユーザー名」、「パスワード」の部分は適切に設定してください。
環境
Rails 2.3.5
次の記事 » Emacs 行番号を表示する