Permalink
Browse files

Improve Errors when Controller Name or Action isn't specfied

These errors occur when, there routes are wrongly defined.

example, the following line would cause a missing :action error

    root "welcomeindex"

Mostly beginners are expected to hit these errors, so lets improve the error message a bit to make their learning experience bit better.
  • Loading branch information...
1 parent 7d17b1d commit 834eb80b597eb07addc5ed706b23f31a9bb37954 @gaurish gaurish committed Nov 2, 2013
Showing with 4 additions and 2 deletions.
  1. +4 −2 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -226,11 +226,13 @@ def default_controller_and_action
action = action.to_s unless action.is_a?(Regexp)
if controller.blank? && segment_keys.exclude?(:controller)
- raise ArgumentError, "missing :controller"
+ message = "Missing :controller key on routes definition, please check your routes."
+ raise ArgumentError, message
end
if action.blank? && segment_keys.exclude?(:action)
- raise ArgumentError, "missing :action"
+ message = "Missing :action key on routes definition, please check your routes."
+ raise ArgumentError, message
end
if controller.is_a?(String) && controller !~ /\A[a-z_0-9\/]*\z/

0 comments on commit 834eb80

Please sign in to comment.