diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-02 12:02:56 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-12 15:54:43 -0700 |
commit | 8d572ad1baa9171253957f174bf88283f84018e8 (patch) | |
tree | 3aa9ff1e159c5f1fc40ffd637e6c1c5c6146e0f3 /actionpack/lib | |
parent | 6eeb76f0411e3d7d78b903601e15a7c7b61ed88b (diff) | |
download | rails-8d572ad1baa9171253957f174bf88283f84018e8.tar.gz rails-8d572ad1baa9171253957f174bf88283f84018e8.tar.bz2 rails-8d572ad1baa9171253957f174bf88283f84018e8.zip |
pull nil checks up
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/polymorphic_routes.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index b749ae0825..582c97679c 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -120,6 +120,10 @@ module ActionDispatch record_list = extract_record_list(record_or_hash_or_array) end + if record_list.empty? || record_list.any?(&:nil?) + raise ArgumentError, "Nil location provided. Can't build URI." + end + record = convert_to_model(record_list.pop) inflection = if options[:action] && options[:action].to_s == "new" @@ -182,14 +186,12 @@ module ActionDispatch def build_route_part(record, inflection) if record.is_a?(Symbol) || record.is_a?(String) record.to_s - elsif record + else if inflection == :singular model_name_from_record_or_class(record).singular_route_key else model_name_from_record_or_class(record).route_key end - else - raise ArgumentError, "Nil location provided. Can't build URI." end end |