From 834eb80b597eb07addc5ed706b23f31a9bb37954 Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Sat, 2 Nov 2013 07:11:37 +0530 Subject: 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. --- actionpack/lib/action_dispatch/routing/mapper.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_dispatch') 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/ -- cgit v1.2.3