Is it possible to specify module in devise_scope in isolated engine

11 views
Skip to first unread message

Simon Iong

unread,
May 13, 2015, 5:59:08 AM5/13/15
to plataforma...@googlegroups.com
I have a engine, which contain devise, and I know there's a `module` option for `devise_for` to make sure all devise controller reside under the scope of engine itself. Please refer to [wiki page here](https://github.com/plataformatec/devise/wiki/How-To:-Use-devise-inside-a-mountable-engine)

But there seem no `module` options for `devise_scope` while I need to custom my devise operations within engine. Anyway, here's my setting:

route.rb in MyEngine
``` ruby 
  devise_for :admins, class_name: "MyEngine::Admin",
                      module: :devise,
                      skip: [:registrations, :passwords]

  devise_scope :admin do
    get 'admins/edit' => 'devise/registrations#edit', :as => 'edit_admin_registration'
    patch 'admins/:id'  => 'admin/registrations#update', :as => 'admin_registration'
  end
```

route.rb in MainApp
``` ruby 
Rails.application.routes.draw do
  mount MyEngine::Engine => "/"
end
```

and while I check the route in my `MainApp`, I found the route setting:
``` ruby
Routes for MyEngine::Engine:
       new_admin_session GET      /admins/sign_in(.:format)              devise/sessions#new
           admin_session POST     /admins/sign_in(.:format)              devise/sessions#create
   destroy_admin_session DELETE   /admins/sign_out(.:format)             devise/sessions#destroy
            admin_unlock POST     /admins/unlock(.:format)               devise/unlocks#create
        new_admin_unlock GET      /admins/unlock/new(.:format)           devise/unlocks#new
                         GET      /admins/unlock(.:format)               devise/unlocks#show
 edit_admin_registration GET      /admins/edit(.:format)                 my_engine/devise/registrations#edit
      admin_registration PATCH    /admins/:id(.:format)                  my_engine/admin/registrations#update
```

The problem is the last 2 route mappings, what I want is to remove "my_engine" prefix.
``` ruby
 edit_admin_registration GET      /admins/edit(.:format)                 devise/registrations#edit
      admin_registration PATCH    /admins/:id(.:format)                  admin/registrations#update
```

Is it possible to add `module` options in devise_scope, or are there any way to archive this?

Reply all
Reply to author
Forward
0 new messages