undefined method `user_signed_in?'

2,962 views
Skip to first unread message

Christian Fazzini

unread,
Sep 27, 2010, 4:48:25 AM9/27/10
to Devise
My routes look like this:

devise_for :users

in my html ive got: <% if user_signed_in? %>...

When I load the page, I get:

undefined method `user_signed_in?'

Isnt this supposed to be a devise helper? So is it not recognising it
as a method helper??

Ive already done gem install devise and rails generate devise:install

cdr53x

unread,
Sep 27, 2010, 5:09:12 AM9/27/10
to plataforma...@googlegroups.com
unsubscribe

Christian Fazzini

unread,
Sep 27, 2010, 5:57:17 AM9/27/10
to Devise
why was the subject changed?

On Sep 27, 5:09 pm, cdr53x <cdr...@free.fr> wrote:
> unsubscribe

Carlos Antonio da Silva

unread,
Sep 27, 2010, 6:56:17 AM9/27/10
to plataforma...@googlegroups.com
Do you have devise call in your model as well?
--
At.
Carlos A. da Silva

Christian Fazzini

unread,
Sep 27, 2010, 7:19:20 AM9/27/10
to Devise
In my user model I have:


devise :registerable, :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable,
:confirmable, :activatable, :encryptor
=> :bcrypt#, :oauthable

On Sep 27, 6:56 pm, Carlos Antonio da Silva
<carlosantoniodasi...@gmail.com> wrote:
> Do you have devise call in your model as well?
>
> On Mon, Sep 27, 2010 at 5:48 AM, Christian Fazzini <
>

Christian Fazzini

unread,
Sep 27, 2010, 8:33:19 AM9/27/10
to Devise
Is this what you were referring to Carlos?

On Sep 27, 6:56 pm, Carlos Antonio da Silva
<carlosantoniodasi...@gmail.com> wrote:
> Do you have devise call in your model as well?
>
> On Mon, Sep 27, 2010 at 5:48 AM, Christian Fazzini <
>

Carlos Antonio da Silva

unread,
Sep 27, 2010, 8:37:09 AM9/27/10
to plataforma...@googlegroups.com
Yes it's, but I can't see anything wrong with your setup. Which Devise version are you using? Did you try regenerating your Gemfile.lock? Please try also inspecting your instance_methods inside the controller to see if you have any of the Devise helpers available.

radhames brito

unread,
Sep 27, 2010, 8:47:01 AM9/27/10
to plataforma...@googlegroups.com

is your model called user???

radhames brito

unread,
Sep 27, 2010, 8:48:15 AM9/27/10
to plataforma...@googlegroups.com

i meant , is there no typos in the model name?

radhames brito

unread,
Sep 27, 2010, 8:49:19 AM9/27/10
to plataforma...@googlegroups.com
and did you restarted the server after the gem installation?

Christian Fazzini

unread,
Sep 27, 2010, 9:57:43 AM9/27/10
to Devise
Radhames, yes restarted..

User model is: class User < ActiveRecord::Base

Carlos:

/Users/Chris/.rvm/gems/ruby-1.9.2-p0/gems/devise-1.1.2

is the version I am using.

Carlos, do I need to load the devise helpers in the controller before
I can use them?

Note, this is a clean install of rails 3

Carlos Antonio da Silva

unread,
Sep 27, 2010, 10:05:56 AM9/27/10
to plataforma...@googlegroups.com
Nope, you don't.
Could you push an example app to Github showing the issue? I can't see anything else now.

radhames brito

unread,
Sep 27, 2010, 10:09:57 AM9/27/10
to plataforma...@googlegroups.com

try any_signed_in? to see if the problem is with the resource_name not mapping right or if the helpers are not loading at all.

radhames brito

unread,
Sep 27, 2010, 10:10:32 AM9/27/10
to plataforma...@googlegroups.com
also try

signed_in?(:user)

Christian Fazzini

unread,
Sep 27, 2010, 10:25:41 AM9/27/10
to Devise
I get undefined method `any_signed_in?'

and with signed_in?(:user), no error. the page loaded fine. I had it
as:

if signed_in?(:user)
puts 'asdf'
end

Now when I remove this block of code, I dont get the error, "undefined
method `user_signed_in?'", very strange. I did not do anything else.

Perhaps the block of code above activated something?


On Sep 27, 10:10 pm, radhames brito <rbri...@gmail.com> wrote:
> also try
>
> signed_in?(:user)

Christian Fazzini

unread,
Sep 27, 2010, 10:35:38 AM9/27/10
to Devise
For some reason, signed_in?(:user) solved the issue....

On Sep 27, 10:25 pm, Christian Fazzini <christian.fazz...@gmail.com>
wrote:

radhames brito

unread,
Sep 27, 2010, 10:46:06 AM9/27/10
to plataforma...@googlegroups.com

strange , maybe carlos has an explanation....carlos?

Carlos Antonio da Silva

unread,
Sep 27, 2010, 10:51:48 AM9/27/10
to plataforma...@googlegroups.com
Actually I don't, seems weird to me also. Unless you've done something really different than the normal setup, it should be working fine...

Are you able to call user_signed_in? inside a controller? Did you add the before_filter?
Also, what Devise.mappings.keys shows to you in the console?


On Mon, Sep 27, 2010 at 11:46 AM, radhames brito <rbr...@gmail.com> wrote:

strange , maybe carlos has an explanation....carlos?



Christian Fazzini

unread,
Sep 27, 2010, 11:12:07 AM9/27/10
to Devise
Yea im actually using it inside ApplicationController

before_filter :set_session_city which has a if condition (if
user_signed_in?), which was causing the problem earlier(undefined
method 'user_signed_in?')

What do you mean by, Devise.mappings.keys? Rake routes?

On Sep 27, 10:51 pm, Carlos Antonio da Silva
<carlosantoniodasi...@gmail.com> wrote:
> Actually I don't, seems weird to me also. Unless you've done something
> really different than the normal setup, it should be working fine...
>
> Are you able to call user_signed_in? inside a controller? Did you add the
> before_filter?
> Also, what Devise.mappings.keys shows to you in the console?
>

radhames brito

unread,
Sep 27, 2010, 11:28:37 AM9/27/10
to plataforma...@googlegroups.com

oppss typo

Devise.mappings.keys


missed the 's'

radhames brito

unread,
Sep 27, 2010, 11:27:48 AM9/27/10
to plataforma...@googlegroups.com
Nope Devise.mappings is a hash that contains the list of model that have devise added to them

put it in any view

<%= Devise.mappings.key%>

should display something like


User....

 and a list of all the models in which you declared Devise

Christian Fazzini

unread,
Sep 27, 2010, 12:00:32 PM9/27/10
to Devise
It returns:

ruby-1.9.2-p0 > Devise.mappings.keys

=> [:user]

radhames brito

unread,
Sep 27, 2010, 1:31:14 PM9/27/10
to plataforma...@googlegroups.com
That means the user model has devise setup so user_signed_in? should work.    :S
Reply all
Reply to author
Forward
0 new messages