Search code examples
ruby-on-rails-4password-protection

Password-Protect a Single Page in Rails


I have a very simple Rails 4.2.4 app that doesn't have or need users. I would, however, like to password-protect a single page (an admin page) which happens to be the index view. Any thoughts?


Solution

  • I added this line to the top of the controller and it works:

    http_basic_authenticate_with :name => "your_name", :password => "your_password", only: :index