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.
http://github.com/rails/rails/blob/be7b64b35aac1c9e9063d1d8317f8b1be2a3411c/actionpack/lib/action_controller/http_authentication.rb#L111

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

Does the code.....

http_basic_authenticate_with :name=>"foo" :password=>"bar"

will this work?