Module: Faalis::RouteHelpers

Included in:
ActionDispatch::Routing::Mapper
Defined in:
lib/faalis/routes.rb

Instance Method Summary collapse

Instance Method Details

#api_routes(version: :v1) ⇒ Object

This method allow user to define his routes in api namespace



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/faalis/routes.rb', line 21

def api_routes(version: :v1)
  # TODO: Add a dynamic solution for formats
  namespace :api, defaults: { format: :json } do
    namespace version do
      # Call user given block to define user routes
      # inside this namespace
      yield if block_given?
    end
  end

  scope 'module'.to_sym => 'faalis' do
    #dashboard = Faalis::Engine.dashboard_namespace
    #get "#{dashboard}/auth/groups/new", to: "#{dashboard}/groups#new"
    get 'auth/profile/edit', to: "profile#edit"
    post 'auth/profile/edit', to: "profile#update"
  end

  # TODO: Add a dynamic solution for formats
  namespace :api, defaults: { format: :json } do
    namespace version do
      get 'permissions',      to: 'permissions#index'
      get 'permissions/user', to: 'permissions#user_permissions'
      resources :groups,      except: [:new]
      resources :users,       except: [:new]
      resource :profile,      except: [:new, :destroy]

      get 'logs', to: 'logs#index'
    end
  end
end

#in_dashboardObject

routes to be added to dashboard



5
6
7
8
9
# File 'lib/faalis/routes.rb', line 5

def in_dashboard
  namespace Faalis::Engine.dashboard_namespace do
    yield
  end
end

#localized_scopeObject

Allow localized scope



12
13
14
15
16
17
# File 'lib/faalis/routes.rb', line 12

def localized_scope
  langs = ::I18n.available_locales.join('|')
  scope '(:locale)', locale: Regexp.new(langs) do
    yield
  end
end