The default controller namespace

62 views
Skip to first unread message

Didde

unread,
Jul 18, 2010, 12:57:48 PM7/18/10
to Devise
Hi Guys,

Sorry to bother you with a question which might seem obvious to some,
but I have failed to find an answer or solution via Google et al.

We're using Devise on a project not yet on Rails 3, hence we roll with
devise-1.0.8 as a gem installation. In this project we need to
override some of the default controllers in order to customize
different behaviors. However, the namespace – or lack there of – in
use prevents us from creating a custom "registrations_controller.rb"
and extending Device's own.

From what I can gather over at GitHub the pre-versions for RoR 3 seems
to use the Devise::Controllers namespace. So, is there a branch or
version in which us still on RoR 2.3 can extend controllers? Or am I
missing something here? :)

At the moment, we route Devise like this:

map.devise_for :users,
:as => "accounts",
:path_names => {
:sign_up => 'register',
:sign_in => 'login',
:sign_out => 'logout',
:password => 'secret',
:confirmation => 'verification',
:unlock => 'unlock'
}

Thanks everyone. We'd really appreciate any input on this matter.

José Valim

unread,
Jul 18, 2010, 1:00:26 PM7/18/10
to plataforma...@googlegroups.com
You need to create a namespaced controller. "users/registrations_controller" or "account/registrations_controller" should do the trick and then you link to them in devise_for, as shown in the documentation.

:)
--
José Valim

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

Didde Brockman

unread,
Jul 18, 2010, 1:11:36 PM7/18/10
to plataforma...@googlegroups.com
Thanks for your answer José! Much obliged.

However, setting the :controllers options in routes.rb seems to confuse things. I have used:

map.devise_for :users,
:as => "accounts",
:path_names => {
:sign_up => 'register',
:sign_in => 'login',
:sign_out => 'logout',
:password => 'secret',
:confirmation => 'verification',
:unlock => 'unlock'
},
:controllers=>{:sessions=>"accounts/registrations"}

...as per the documentation to no avail. Does anyone know of a concrete example in which the above works for a registrations controller?


/didde

José Valim

unread,
Jul 18, 2010, 1:13:54 PM7/18/10
to plataforma...@googlegroups.com
Hrm, now that you said it, I think such configurations does not work at all in Rails 2.3. I think people would rather: 1) copy the whole controller 2) use another controller but would manually create the routes before devise_for call.

Didde Brockman

unread,
Jul 18, 2010, 1:26:53 PM7/18/10
to plataforma...@googlegroups.com
Oh man. Neither of those methods seem dry to me  :)

Manually creating the routes and assigning my own "namespaced" controllers seems like the lesser of two evils. Does anyone know a existing reference for creating the routes in routes.rb?


/didde
Reply all
Reply to author
Forward
0 new messages