Module ActionController::PolymorphicRoutes
In: vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb

Methods

Public Instance methods

[Source]

    # File vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb, line 30
30:     def polymorphic_path(record_or_hash_or_array)
31:       polymorphic_url(record_or_hash_or_array, :routing_type => :path)
32:     end

[Source]

    # File vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb, line 3
 3:     def polymorphic_url(record_or_hash_or_array, options = {})
 4:       record = extract_record(record_or_hash_or_array)
 5: 
 6:       namespace = extract_namespace(record_or_hash_or_array)
 7:       
 8:       args = case record_or_hash_or_array
 9:         when Hash;  [ record_or_hash_or_array ]
10:         when Array; record_or_hash_or_array.dup
11:         else        [ record_or_hash_or_array ]
12:       end
13: 
14:       inflection =
15:         case
16:         when options[:action] == "new"
17:           args.pop
18:           :singular
19:         when record.respond_to?(:new_record?) && record.new_record?
20:           args.pop
21:           :plural
22:         else
23:           :singular
24:         end
25:       
26:       named_route = build_named_route_call(record_or_hash_or_array, namespace, inflection, options)
27:       send!(named_route, *args)
28:     end

[Validate]