Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/action_admin/routes.rb

Instance Method Summary collapse

Instance Method Details

#authenticate_admin(resource, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/action_admin/routes.rb', line 3

def authenticate_admin(resource, options={})
  space   = options.fetch :namespace, :admin
  path    = options.fetch :path, "#{space}/#{resource}"
  model   = "#{resource}".pluralize
  names   = { sign_in: 'login', sign_out: 'logout', sign_up: 'signup', edit: 'profile' }
  options = { path: path, path_names: names, module: 'action_admin/devise' }.merge(options)

  devise_for :"#{model}", options

  authenticate resource do
    namespace space do
      yield
    end
  end
end