diff options
author | Damien Mathieu <42@dmathieu.com> | 2011-07-02 18:02:43 +0200 |
---|---|---|
committer | Damien Mathieu <42@dmathieu.com> | 2011-07-02 18:53:54 +0200 |
commit | ac15bcebf2d560a34286ffba7ed6a687574f2d9d (patch) | |
tree | 1031021cbc569ce800c99a0d33edc5eaef00be2e /actionpack/lib | |
parent | 908be47781de892779639d5ae83b3471d46e6e48 (diff) | |
download | rails-ac15bcebf2d560a34286ffba7ed6a687574f2d9d.tar.gz rails-ac15bcebf2d560a34286ffba7ed6a687574f2d9d.tar.bz2 rails-ac15bcebf2d560a34286ffba7ed6a687574f2d9d.zip |
provide a more explicit message when using url_for with nil
This fixes the problem of having a non-explicit message when the :location option is not provided in respond_with.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index 82c4fadb50..49aef0bf72 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -182,10 +182,12 @@ module ActionDispatch if record.is_a?(Symbol) || record.is_a?(String) route << record - else + elsif record route << ActiveModel::Naming.route_key(record) route = [route.join("_").singularize] if inflection == :singular route << "index" if ActiveModel::Naming.uncountable?(record) && inflection == :plural + else + raise ArgumentError, "Nil location provided. Can't build URI." end route << routing_type(options) |