HTTP Basic Authentication

I’m trying to HTTP Basic Authentication mentioned at
http://railscasts.com/episodes/82-http-basic-authentication

I’m trying to understand the document.

The RailsCasts sample is:

def authenticate
authenticate_or_request_with_http_basic do |username, password|
username == “foo” && password == “bar”
end
end

But I would like to change “realm” as well. It looks possible in the
documentation. But I don’t understand how to do it because my
understanding of block in Ruby isn’t good.

Can anybody give me a sample that uses “realm”?

John

Try:

authenticate_or_request_with_http_basic(‘YourRealm’) do |username,
password|
username == “foo” && password == “bar”
end

Dmitry

Thanks. That’s how I can pass the first argument. Now I understand.

Thanks.

John

On Wed, Apr 22, 2009 at 10:49 PM, Dmitry S.

Does the code…

http_basic_authenticate_with :name=>“foo” :password=>“bar”

will this work?