# problem with authenticate

**URL:** <https://discuss.rubyonrails.org/t/problem-with-authenticate/58983>\
**Category:** rubyonrails-talk\
**Created:** [May 15, 2011, 11:14pm UTC](https://discuss.rubyonrails.org/t/problem-with-authenticate/58983 "2011-05-15T23:14:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![compusaurus](https://avatars.discourse-cdn.com/v4/letter/c/ec9cab/32.png) [@compusaurus](https://discuss.rubyonrails.org/u/compusaurus)\
**Post date:** [May 15, 2011, 11:14pm UTC](https://discuss.rubyonrails.org/t/problem-with-authenticate/58983/1 "2011-05-15T23:14:07Z")

</div>

The example doesn't work as described for me; not sure if I haven't followed it right, or there's a problem with the code. Can someone help me to determine what the problem is.

Specifically, after adding the authentication code to the ApplicationController , with this code:

&nbsp;&nbsp;def authenticate &nbsp;&nbsp;&nbsp;&nbsp;authenticate\_or\_request\_with\_http\_basic do |user\_name, password| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;user\_name == 'admin' && password == 'password' &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;end

And then to the PostsController, with this line:

before\_filter :authenticate, :except =\> [:index, :show]

The guide says that "we want the user to be authenticated on every action, except for index and show", however, it only authenticates on the new post and edit options; it doesn't authenticate on destroy.

Sincere thanks in advance to anyone who can help shed light on this issue! 🙂

Here's the full code of each:

---

<div class="post-metadata">

**Author:** ![Tom\_Meinlschmidt](https://avatars.discourse-cdn.com/v4/letter/t/c89c15/32.png) [@Tom\_Meinlschmidt](https://discuss.rubyonrails.org/u/Tom_Meinlschmidt)\
**Post date:** [May 15, 2011, 11:20pm UTC](https://discuss.rubyonrails.org/t/problem-with-authenticate/58983/2 "2011-05-15T23:20:57Z")

</div>

hi,

some error messages in the log?

tom
