Module: Adminpanel::RouterHelper
- Included in:
- ApplicationController
- Defined in:
- app/helpers/adminpanel/router_helper.rb
Instance Method Summary collapse
- #adminpanel_resources ⇒ Object
- #default_controllers ⇒ Object
- #find_resources ⇒ Object
- #menu_items ⇒ Object
- #resources_path ⇒ Object
Instance Method Details
#adminpanel_resources ⇒ Object
3 4 5 |
# File 'app/helpers/adminpanel/router_helper.rb', line 3 def adminpanel_resources @files ||= find_resources end |
#default_controllers ⇒ Object
25 26 27 |
# File 'app/helpers/adminpanel/router_helper.rb', line 25 def default_controllers ["application_controller.rb", "sessions_controller.rb", "galleries_controller.rb", "users_controller.rb", "sections_controller.rb"] end |
#find_resources ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/helpers/adminpanel/router_helper.rb', line 7 def find_resources resources_path if File.directory?(resources_path) files = Dir.entries(resources_path).collect do |f| unless default_controllers.include?(f) file_path = "#{resources_path}#{f}" File.file?(file_path) ? file_path.sub!(resources_path, '').sub!('_controller.rb', '') : nil end end files.compact! end end |
#menu_items ⇒ Object
21 22 23 |
# File 'app/helpers/adminpanel/router_helper.rb', line 21 def @menu ||= adminpanel_resources.each.collect { |resource| resource.classify } end |
#resources_path ⇒ Object
29 30 31 |
# File 'app/helpers/adminpanel/router_helper.rb', line 29 def resources_path "#{Rails.root.to_s}/app/controllers/adminpanel/" end |