diff options
author | Gaurish Sharma <contact@gaurishsharma.com> | 2013-11-02 07:11:37 +0530 |
---|---|---|
committer | Gaurish Sharma <contact@gaurishsharma.com> | 2013-11-05 19:58:07 +0530 |
commit | 834eb80b597eb07addc5ed706b23f31a9bb37954 (patch) | |
tree | 198da97313a9b642e9ac0ed08cdac5f94b5c1bf7 /actionpack/lib | |
parent | 7d17b1dedbce7daf5c5c5b39eff1c2f5661fab0e (diff) | |
download | rails-834eb80b597eb07addc5ed706b23f31a9bb37954.tar.gz rails-834eb80b597eb07addc5ed706b23f31a9bb37954.tar.bz2 rails-834eb80b597eb07addc5ed706b23f31a9bb37954.zip |
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.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index db9c993590..cd5220548c 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -226,11 +226,13 @@ module ActionDispatch 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/ |