Have devise_for inside a namespace?

2,241 views
Skip to first unread message

Jeroen

unread,
Feb 23, 2010, 2:47:19 PM2/23/10
to Devise
Hi,

I'm trying to have the following routes:

/admin/sign_in
/admin/sign_out

In order to do this i have the following in routes.rb:

devise_for :admin

namespace :admin do
root :to => 'admin/welcome#index'
end

My model is User. When i have the above code and i run rake routes, i
get an error:

undefined method `devise_modules' for #<Module:0x00000103488518>

Perhaps this is caused by my model named User instead of Admin?

Is there a way to get this to work?

Thanks,
Jeroen

p.s. The devise_views generator generates the views in the root rails
app dir, *not* in app/views (copied them manually there).

José Valim

unread,
Feb 23, 2010, 2:49:50 PM2/23/10
to plataforma...@googlegroups.com
This is for Rails 3? Which Devise version?

Please pastie your Gemfile and config/application.rb.
--
José Valim

Director of Engineering - Plataforma Tecnologia
Know more about us: http://plataformatec.com.br/en/

Jeroen

unread,
Feb 23, 2010, 3:06:45 PM2/23/10
to Devise
Yep, this is with rails 3 and devise from git:

source 'http://gemcutter.org'

## Bundle edge rails:
gem "rails", "3.0.0.beta1", :git => "git://github.com/rails/rails.git"

## Bundle the gems you use:
gem "devise", :git => "git://github.com/plataformatec/devise.git"
gem "mysql"
gem "warden", "0.9.4"

My application.rb is still the default generated one.

Jeroen

On Feb 23, 8:49 pm, José Valim <jose.va...@gmail.com> wrote:
> This is for Rails 3? Which Devise version?
>
> Please pastie your Gemfile and config/application.rb.
>

José Valim

unread,
Feb 23, 2010, 3:08:53 PM2/23/10
to plataforma...@googlegroups.com
Please post the error backtrace as well!

Jeroen

unread,
Feb 23, 2010, 3:12:54 PM2/23/10
to Devise
Here you go: http://gist.github.com/312655

On Feb 23, 9:08 pm, José Valim <jose.va...@gmail.com> wrote:
> Please post the error backtrace as well!
>

José Valim

unread,
Feb 23, 2010, 3:16:15 PM2/23/10
to plataforma...@googlegroups.com
Wait. When you do:

  devise_for :admins

It uses Admin. If you are using another model, you have to specify it:

  devise_for :admins, :class_name => "User"

This information is in the documentation as well.

On Tue, Feb 23, 2010 at 9:06 PM, Jeroen <jeroen.zw...@gmail.com> wrote:

Jeroen

unread,
Feb 23, 2010, 3:23:26 PM2/23/10
to Devise
Thanks, you're right. Works ok now. I found the docs @
http://rdoc.info/projects/plataformatec/devise

Jeroen

On Feb 23, 9:16 pm, José Valim <jose.va...@gmail.com> wrote:
> Wait. When you do:
>
>   devise_for :admins
>
> It uses Admin. If you are using another model, you have to specify it:
>
>   devise_for :admins, :class_name => "User"
>
> This information is in the documentation as well.
>

Reply all
Reply to author
Forward
0 new messages