# Restful auth problem

**URL:** <https://www.ruby-forum.com/t/restful-auth-problem/155887>\
**Category:** Rails\
**Created:** [December 17, 2008, 10:11pm UTC](https://www.ruby-forum.com/t/restful-auth-problem/155887 "2008-12-17T22:11:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bouldr-matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@bouldr-matt](https://www.ruby-forum.com/u/bouldr-matt)\
**Post date:** [December 17, 2008, 10:11pm UTC](https://www.ruby-forum.com/t/restful-auth-problem/155887/1 "2008-12-17T22:11:15Z")

</div>

Hi folks,

I have been working on a website and I used restful auth as a starting  
point for the authentication.

Suddenly (I don’t think I broke it but I don’t know) it has started  
throwing me a weird problem.

I have a view that checks to see if the user is logged in (logged\_in?)  
and if yes, check the user’s roles (current\_user.has\_role?) and display  
a menu accordingly.

The login check seems to return true for non-authenticated users and  
thus falls over when it tries to get the roles (no method:  
nil.has\_role?)

I have definitely not fiddled with the restful auth libs, like  
authenticated\_system.rb. I have gone back and checked the svn logs to  
see what else I might have broken, but I can’t find a trace.

I don’t know where to start tracking this problem down, I looked at the  
code for logged\_in? and it’s so simple I don’t see how it could have got  
broken.

Any ideas welcomed as I’m pretty much stuck

Thanks

Matt

---

<div class="post-metadata">

**Author:** ![bouldr-matt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/85e7bf/32.png) [@bouldr-matt](https://www.ruby-forum.com/u/bouldr-matt)\
**Post date:** [December 18, 2008, 12:09am UTC](https://www.ruby-forum.com/t/restful-auth-problem/155887/2 "2008-12-18T00:09:44Z")

</div>

Solved…embarrasingly.

I was looking at the wrong line…doh

The actual problem was I had used “has\_role?” later on in the layout but  
hadn’t wrapped it with “if logged\_in?”.

Lets just keep quiet about this one 😛
