Master ruby with us

HTTP authentication for Ruby on Rails application

Posted by firstruby on June 23, 2011

You may want to add HTTP authentication to your Ruby on Rails site, add following to your application controller file,

before_filter :authenticate


def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == "test" && password == "test"

After adding these lines, application will ask for username and password.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: