On Apr 17, 2006, at 17:50, David Heinemeier Hansson wrote:

2. If it does need special handling because of some rationale I am
not aware of, should we document :id has to go necessarily into
options and not into :params?

:id is special, just like :action and :controller is. Routing is built
around these three parameters getting special treatment. So let's
document that :id should not be named in params, but on its own.

In url_for we start with options, then update options with options [:params], if any, and then we pass the resulting hash to routing:

      def rewrite_path(options)
        options = options.symbolize_keys
options.update(options[:params].symbolize_keys) if options [:params]
        if (overwrite = options.delete(:overwrite_params))
          options.update(@parameters.symbolize_keys)
          options.update(overwrite)
        end
        RESERVED_OPTIONS.each {|k| options.delete k}
path, extra_keys = Routing::Routes.generate(options.dup, @request)

path << build_query_string(options, extra_keys) unless extra_keys.empty?

        path
      end

So if a programmer sees :id as one among other request parameters in some particular call, only default routing rules beautifies it, he still gets a valid URL, instead of a hard-coded nil for :id. Wouldn't it be natural to replicate that behaviour in render_component?

-- fxn

_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to