# Why is authenticate\_with\_http\_basic undefined?

**URL:** <https://www.ruby-forum.com/t/why-is-authenticate-with-http-basic-undefined/122826>\
**Category:** Rails\
**Created:** [December 12, 2007, 5:43pm UTC](https://www.ruby-forum.com/t/why-is-authenticate-with-http-basic-undefined/122826 "2007-12-12T17:43:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kei\_Simone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/839c29/32.png) [@Kei\_Simone](https://www.ruby-forum.com/u/Kei_Simone)\
**Post date:** [December 12, 2007, 5:43pm UTC](https://www.ruby-forum.com/t/why-is-authenticate-with-http-basic-undefined/122826/1 "2007-12-12T17:43:21Z")

</div>

Hi,

i used the rick olson’s restful\_authentication plugin

rails 1.2.6

i wanted to check for authenticated user so i wrote this in my  
application.rb

# Filters

before\_filter :authenticate

# Sets @authenticated\_user if the user provides valid

# credentials. May be used to deny access or customise the view

def authenticate  
@authenticated\_user = nil  
authenticate\_with\_http\_basic do |user, pass|

```
  @authenticated_user = User.authenticate(user, pass)
end

return true

```

end

#Filter for actions that _require_ authentication. Unless client  
authenticated

# as some user, takes over the request and sends a response code of

1. 

def must\_authenticate  
if @authenticated\_user && (@user\_is\_viewing\_themselves != false)  
return true  
else  
request\_http\_basic\_authentication  
return false  
end  
end

I get a NOMETHODERROR

undefined method `request\_http\_basic\_authentication’ for  
#OrdersController:0x478cc5c

when i tried this url  
[http://localhost:3001/v1/users/permalink\_for\_user\_1/orders](http://localhost:3001/v1/users/permalink_for_user_1/orders)

if i remove the filter , etc i can use this link which is of course  
bad cause i also can see teh data when i am not the authenticated  
user.

Please help.

Thank you

---

<div class="post-metadata">

**Author:** ![Kei\_Simone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/839c29/32.png) [@Kei\_Simone](https://www.ruby-forum.com/u/Kei_Simone)\
**Post date:** [December 12, 2007, 6:27pm UTC](https://www.ruby-forum.com/t/why-is-authenticate-with-http-basic-undefined/122826/2 "2007-12-12T18:27:46Z")

</div>

> i used the rick olson’s restful\_authentication plugin
> 
> rails 1.2.6

I’m pretty sure that authenticate\_with\_http\_basic is a rails 2.0  
feature.

Check the docs/release notes…
