Topic: restful_authentication- undefined method 'authenticate_with_http_basic

I get the following error:

undefined method `authenticate_with_http_basic' for #<ActionView::Base:0x45d2e5c>

when I try to render the following partial:

<% if logged_in? -%>
  <div id="user-bar-greeting">Logged in as <%= link_to_current_user :content_method => :login %></div>
  <div id="user-bar-action"  >(<%= link_to "Log out", logout_path, { :title => "Log out" }    %>)</div>
<% else -%>
  <div id="user-bar-greeting"><%= link_to_login_with_IP 'Not logged in', :style => 'border: none;' %></div>
  <div id="user-bar-action"  ><%= link_to "Log in",  login_path,  { :title => "Log in" } %> /
                               <%= link_to "Sign up", signup_path, { :title => "Create an account" } %></div>
<% end -%>

However, it works fine, when I'm logged in. If not, it will create the error above.

Ruby version    1.8.6 (i386-mswin32)
RubyGems version    1.3.5
Rack version    1.0
Rails version    2.3.5

Can anybody help me?

I'm still trying to understand to problem. In the meantime I have also installed the restful_authentication tutorial application  and tried the code snippet there. Here logged_in? works in both situation, i.e. when logged in and when logged out.

The trace looks like this:

PATH/authenticated_system.rb:113:in `login_from_basic_auth'
PATH/lib/authenticated_system.rb:12:in `current_user'
PATH/lib/authenticated_system.rb:6:in `logged_in?'

Re: restful_authentication- undefined method 'authenticate_with_http_basic

Is there really nobody, who could help me?

Re: restful_authentication- undefined method 'authenticate_with_http_basic

I just wanted to follow up with this thread in case anyone else sees this issue. I get the error:

undefined method `http_basic_authenticate_with' for #<RubricsController:0x007f0e4c2e2370>

...when including this code at the top of my controller...

  http_basic_authenticate_with :name => "dhh", :password => "secret", :except => :index

This is odd because its pulled directly from the infamous Rails 3 Blog Tutorial here:

http://guides.rubyonrails.org/getting_s … l#security

If anyone knows what the problem is, I'd love to hear it. Who knows how many folks have not gotten this to work.

As an alternative you can do this http://lukaszwrobel.pl/blog/http-basic- … n-in-rails which works in Rails 3.