-
-
Save talsafran/dd1d9102e4354444d84c to your computer and use it in GitHub Desktop.
Adding HTTP authentication to protect your posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this to app/controllers/posts_controller.rb, right after the PostsController | |
# class is declared. | |
http_basic_authenticate_with name: "some_username", password: "some_password", only: [:index, :new, :create, :edit, :update, :destroy] | |
# Of course, you can also use this shorter method | |
http_basic_authenticate_with name: "some_username", password: "some_password", except: :show | |
# For more information, check out this Rails Guide | |
# http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment