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

posted by Png genki on Wed 1 Apr 2009 at 13:18

Comments:

or Preview
Social Bookmarks
  • Delicious
  • B_entry1392
  • Clip_16_12_w
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ