# Strange acts\_as\_authenticated code in account/index action

**URL:** <https://www.ruby-forum.com/t/strange-acts-as-authenticated-code-in-account-index-action/113445>\
**Category:** Rails\
**Created:** [August 31, 2007, 4:07am UTC](https://www.ruby-forum.com/t/strange-acts-as-authenticated-code-in-account-index-action/113445 "2007-08-31T04:07:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mhfs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b2d939/32.png) [@mhfs](https://www.ruby-forum.com/u/mhfs)\
**Post date:** [August 31, 2007, 4:07am UTC](https://www.ruby-forum.com/t/strange-acts-as-authenticated-code-in-account-index-action/113445/1 "2007-08-31T04:07:20Z")

</div>

Hello,

I’m using the acts\_as\_authenticated plugin. I have not yet modified the  
AccountController much. All the default actions are still there  
untouched.

Then, I noted a strange behaviour: When the user **is not** logged on  
and  
tries to access the account/index action, the redirect to the signup  
page is  
not made.

Here’s the code for the index action of the AccountController  
controller:

# say something nice, you goof! something sweet.

def index  
redirect\_to(:action =\> ‘signup’) unless logged\_in? || User.count \> 0  
end

## There is the || User.count \> 0 ? It is causing me problems, here is why

when the user is not logged in, the logged\_in? returns false, but being  
an  
OR operation, if the User.count \> 0, true prevails, so, it assumes the  
user  
is logged in when there is a user in the database.

Here’s the full controller code:  
[http://pastie.caboo.se/92641](http://pastie.caboo.se/92641)

Does anyone know why the author did that?

Thanks in advance,

Marcelo.
