Module: ActionNotFound
- Extended by:
- ActionNotFound
- Included in:
- ActionNotFound
- Defined in:
- lib/action_not_found.rb,
lib/action_not_found/railtie.rb,
lib/action_not_found/version.rb
Defined Under Namespace
Classes: Railtie
Constant Summary collapse
- VERSION =
"0.0.6"
Instance Method Summary collapse
- #formatted_action_not_found(formatted, base_path) ⇒ Object
- #process(all_routes, base_path) ⇒ Object
- #process_rails_3_2(all_routes) ⇒ Object
- #process_rails_4(all_routes) ⇒ Object
Instance Method Details
#formatted_action_not_found(formatted, base_path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/action_not_found.rb', line 16 def formatted_action_not_found(formatted, base_path) not_found_controller_count = 0 not_found_action_count = 0 formatted_action_not_found = formatted.each do |route| route =~ /\/(.*?)\s+(.*?)#(.*?)$/ controller_path = base_path.join("#{$2}_controller.rb") begin unless File.readlines(controller_path).grep(/def\s#{$3}/).size > 0 route << " #=> not found action" not_found_action_count += 1 end rescue route << " #=> not found controller file" not_found_controller_count += 1 end end formatted_action_not_found.push("\n#{formatted.size} routes, #{not_found_action_count} not found actions, #{not_found_controller_count} not controller files") end |
#process(all_routes, base_path) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/action_not_found.rb', line 6 def process(all_routes, base_path) formatted = case Rails.version when /^3\.2/ process_rails_3_2(all_routes) else process_rails_4(all_routes) end formatted_action_not_found(formatted, base_path) end |
#process_rails_3_2(all_routes) ⇒ Object
35 36 37 38 |
# File 'lib/action_not_found.rb', line 35 def process_rails_3_2(all_routes) require 'rails/application/route_inspector' Rails::Application::RouteInspector.new.format(all_routes) end |
#process_rails_4(all_routes) ⇒ Object
40 41 42 43 |
# File 'lib/action_not_found.rb', line 40 def process_rails_4(all_routes) require 'action_dispatch/routing/inspector' ActionDispatch::Routing::RoutesInspector.new.format(all_routes) end |