Have devise_for inside a namespace?

Showing 1-7 of 7 messages
Have devise_for inside a namespace? Jeroen 2/23/10 11:47 AM
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).

Re: [devise] Have devise_for inside a namespace? José Valim 2/23/10 11:49 AM
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/
Re: Have devise_for inside a namespace? Jeroen 2/23/10 12:06 PM
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.
>
> On Tue, Feb 23, 2010 at 8:47 PM, Jeroen <jeroen.zwartepoo...@gmail.com>wrote:
>
>
>
>
>
> > 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
>
> Director of Engineering - Plataforma Tecnologia
> Know more about us:http://plataformatec.com.br/en/

Re: [devise] Re: Have devise_for inside a namespace? José Valim 2/23/10 12:08 PM
Please post the error backtrace as well!
Re: Have devise_for inside a namespace? Jeroen 2/23/10 12:12 PM
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!
>

Re: [devise] Re: Have devise_for inside a namespace? José Valim 2/23/10 12:16 PM
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:
Re: Have devise_for inside a namespace? Jeroen 2/23/10 12:23 PM
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.
>