polymorphic_urlの中身で使われている build_named_route_callのソースを貼付けておきます。
1 def build_named_route_call(records, namespace, inflection, options = {})
2 unless records.is_a?(Array)
3 record = extract_record(records)
4 route = ''
5 else
6 record = records.pop
7 route = records.inject("") do |string, parent|
8 if parent.is_a?(Symbol) || parent.is_a?(String)
9 string << "#{parent}_"
10 else
11 string << "#{RecordIdentifier.__send__("plural_class_name", parent
12 )}".singularize
13 string << "_"
14 end
15 end
16 end
17
18 if record.is_a?(Symbol) || record.is_a?(String)
19 route << "#{record}_"
20 else
21 route << "#{RecordIdentifier.__send__("plural_class_name", record)}"
22 route = route.singularize if inflection == :singular
23 route << "_"
24 end
25
26 action_prefix(options) + namespace + route + routing_type(options).to_s
27 end