Class: ForgeController

Inherits:
ApplicationController show all
Defined in:
lib/forge/app/controllers/forge_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#app_init

Instance Method Details

#get_menu_itemsObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/forge/app/controllers/forge_controller.rb', line 18

def get_menu_items
  require 'rails/application/route_inspector'

  # Read the routes to find out which partials to load to build the menu
  inspector = Rails::Application::RouteInspector.new
  controllers = inspector.collect_routes(Rails.application.routes.routes).select do |route|
    route[:reqs].match('forge')
  end.map do |route|
    route[:reqs].gsub('forge/', '').gsub(/#.*/, '')
  end
  @menu_items = controllers.reject {|c| c == "index"}.uniq!
end

#load_helpObject



14
15
16
# File 'lib/forge/app/controllers/forge_controller.rb', line 14

def load_help
  @help_slug = "#{params[:controller].split('/')[1]}_#{params[:action]}"
end

#set_crumbsObject



31
32
33
34
# File 'lib/forge/app/controllers/forge_controller.rb', line 31

def set_crumbs
  @controller_crumb = params[:controller]
  @action_crumb = params[:action]
end

#set_titleObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/forge/app/controllers/forge_controller.rb', line 36

def set_title
  case params[:action]
    when "new", "create"
      @page_title = "New #{params[:controller].gsub('forge/', '').singularize.humanize} - Forge".titleize
    when "edit", "update"
      @page_title = "Edit #{params[:controller].gsub('forge/', '').singularize.humanize} - Forge".titleize
    else
      @page_title = params[:controller].gsub('forge/', '').humanize.titleize + " - Forge"
    end
  @page_title = "Forge" if params[:controller].gsub('forge/', '') == "index"
end

#uses_ckeditorObject



10
11
12
# File 'lib/forge/app/controllers/forge_controller.rb', line 10

def uses_ckeditor
  @uses_ckeditor = true
end