Posted on 2008年10月6日 Posted by ちゅう 1件のコメント Posted in Development Tags: Rails デフォルトで用意されている Basic 認証の仕組みの使い方。ユーザ名 chihaya, パスワード password72 とすると、以下のようにして行える。 Rails5.1以降 class ApplicationController < ActionController::Base http_basic_authenticate_with name name: 'chihaya', password: 'password72' unless Rails.env.production? end 特定の処理でスキップしたい場合、 except を使うか、before_action で処理する # except を使う場合 class Na
![Rails で Basic認証する方法 | 変なヤバいもんログ](https://cdn-ak-scissors.b.st-hatena.com/image/square/2bb579ca026c1eecce39f8b35818ed91d3490d63/height=288;version=1;width=512/https%3A%2F%2Fecpplus.net%2Fweblog%2Fwp-content%2Fuploads%2F2011%2F08%2Fruby_on_rails.png)