Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 6751

Show
Ignore:
Timestamp:
05/18/07 00:36:14 (1 year ago)
Author:
bitsweat
Message:

Clean up the simply_helpful merge.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/base.rb

    r6750 r6751  
    561561            @url.rewrite(rewrite_options(options)) 
    562562          else 
    563             polymorphic_url(options, self
     563            polymorphic_url(options
    564564        end 
    565565      end 
     
    10351035          else 
    10361036            redirect_to(url_for(options)) 
    1037             response.redirected_to = options 
    10381037        end 
    10391038      end 
  • trunk/actionpack/lib/action_controller/polymorphic_routes.rb

    r6731 r6751  
    11module ActionController 
    22  module PolymorphicRoutes 
    3     extend self 
    4  
    5     def polymorphic_url(record_or_hash, url_writer, options = {}) 
     3    def polymorphic_url(record_or_hash, options = {}) 
    64      record = extract_record(record_or_hash) 
    75 
    86      case 
    97      when options[:action] == "new" 
    10         url_writer.send( 
     8        send( 
    119          action_prefix(options) + RecordIdentifier.singular_class_name(record) + routing_type(options) 
    1210        ) 
    1311 
    1412      when record.respond_to?(:new_record?) && record.new_record? 
    15         url_writer.send( 
     13        send( 
    1614          action_prefix(options) + RecordIdentifier.plural_class_name(record) + routing_type(options) 
    1715        ) 
    1816 
    1917      else 
    20         url_writer.send( 
     18        send( 
    2119          action_prefix(options) + RecordIdentifier.singular_class_name(record) + routing_type(options), record_or_hash 
    2220        ) 
     
    2422    end 
    2523 
    26     def polymorphic_path(record_or_hash, url_writer
    27       polymorphic_url(record_or_hash, url_writer, :routing_type => :path) 
     24    def polymorphic_path(record_or_hash
     25      polymorphic_url(record_or_hash, :routing_type => :path) 
    2826    end 
    2927 
    3028    %w( edit new formatted ).each do |action| 
    31       module_eval <<-EOT 
    32         def #{action}_polymorphic_url(record_or_hash, url_writer
    33           polymorphic_url(record_or_hash, url_writer, :action => "#{action}") 
     29      module_eval <<-EOT, __FILE__, __LINE__ 
     30        def #{action}_polymorphic_url(record_or_hash
     31          polymorphic_url(record_or_hash, :action => "#{action}") 
    3432        end 
    3533 
    36         def #{action}_polymorphic_path(record_or_hash, url_writer
    37           polymorphic_url(record_or_hash, url_writer, :action => "#{action}", :routing_type => :path) 
     34        def #{action}_polymorphic_path(record_or_hash
     35          polymorphic_url(record_or_hash, :action => "#{action}", :routing_type => :path) 
    3836        end 
    3937      EOT 
     
    4543        options[:action] ? "#{options[:action]}_" : "" 
    4644      end 
    47        
     45 
    4846      def routing_type(options) 
    4947        "_#{options[:routing_type] || "url"}" 
    5048      end 
    51        
     49 
    5250      def extract_record(record_or_hash) 
    5351        record_or_hash.is_a?(Hash) ? record_or_hash[:id] : record_or_hash 
  • trunk/actionpack/lib/action_view/helpers/form_helper.rb

    r6731 r6751  
    168168          object_name = ActionController::RecordIdentifier.singular_class_name(record_or_name) 
    169169          apply_form_for_options!(object, options) 
     170          args.unshift object 
    170171        end 
    171172 
     
    185186        options[:html].reverse_merge!(html_options) 
    186187 
    187         options[:url] ||= polymorphic_path(object, self)         
     188        options[:url] ||= polymorphic_path(object) 
    188189      end 
    189190 
  • trunk/actionpack/lib/action_view/helpers/prototype_helper.rb

    r6731 r6751  
    192192          object_name = ActionController::RecordIdentifier.singular_class_name(record_or_name) 
    193193          apply_form_for_options!(object, options) 
     194          args.unshift object 
    194195        end 
    195196 
  • trunk/actionpack/lib/action_view/helpers/url_helper.rb

    r6729 r6751  
    7676        else 
    7777          escape = false 
    78           url    = polymorphic_path(options, self
     78          url    = polymorphic_path(options
    7979        end 
    8080 
  • trunk/actionpack/lib/action_view/partials.rb

    r6404 r6751  
    4949      # Deprecated, use render :partial 
    5050      def render_partial(partial_path, local_assigns = nil, deprecated_local_assigns = nil) #:nodoc: 
    51         path, partial_name = partial_pieces(partial_path) 
    52         object = extracting_object(partial_name, local_assigns, deprecated_local_assigns) 
    53         local_assigns = extract_local_assigns(local_assigns, deprecated_local_assigns) 
    54         local_assigns = local_assigns ? local_assigns.clone : {} 
    55         add_counter_to_local_assigns!(partial_name, local_assigns) 
    56         add_object_to_local_assigns!(partial_name, local_assigns, object) 
     51        case partial_path 
     52        when String, Symbol, NilClass 
     53          path, partial_name = partial_pieces(partial_path) 
     54          object = extracting_object(partial_name, local_assigns, deprecated_local_assigns) 
     55          local_assigns = extract_local_assigns(local_assigns, deprecated_local_assigns) 
     56          local_assigns = local_assigns ? local_assigns.clone : {} 
     57          add_counter_to_local_assigns!(partial_name, local_assigns) 
     58          add_object_to_local_assigns!(partial_name, local_assigns, object) 
    5759 
    58         if logger 
    59           ActionController::Base.benchmark("Rendered #{path}/_#{partial_name}", Logger::DEBUG, false) do 
     60          if logger 
     61            ActionController::Base.benchmark("Rendered #{path}/_#{partial_name}", Logger::DEBUG, false) do 
     62              render("#{path}/_#{partial_name}", local_assigns) 
     63            end 
     64          else 
    6065            render("#{path}/_#{partial_name}", local_assigns) 
    6166          end 
     67        when Array 
     68          if partial_path.any? 
     69            path       = ActionController::RecordIdentifier.partial_path(partial_path.first) 
     70            collection = partial_path 
     71            render_partial_collection(path, collection, nil, local_assigns.value) 
     72          else 
     73            "" 
     74          end 
    6275        else 
    63           render("#{path}/_#{partial_name}", local_assigns) 
     76          render_partial( 
     77            ActionController::RecordIdentifier.partial_path(partial_path), 
     78            local_assigns, deprecated_local_assigns) 
    6479        end 
    6580      end 
  • trunk/actionpack/test/template/form_helper_test.rb

    r6731 r6751  
    602602 
    603603  protected 
    604     def polymorphic_path(record, url_writer
     604    def polymorphic_path(record
    605605      if record.new_record? 
    606606        "/posts" 
  • trunk/actionpack/test/template/prototype_helper_test.rb

    r6731 r6751  
    215215    end 
    216216   
    217     def polymorphic_path(record, url_writer
     217    def polymorphic_path(record
    218218      if record.new_record? 
    219219        "/authors"