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

Changeset 5700

Show
Ignore:
Timestamp:
12/07/06 02:37:33 (2 years ago)
Author:
david
Message:

Renamed named_route to polymorphic_url and added polymorphic_path as well as making both available to controllers and views

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/simply_helpful/lib/simply_helpful/controller_extensions.rb

    r5609 r5700  
    11module SimplyHelpful 
    22  module ActionControllerExtensions 
     3    def self.included(base) 
     4      base.helper_method :polymorphic_url 
     5      base.helper_method :polymorphic_path 
     6    end 
     7 
     8    def polymorphic_url(record) 
     9      SimplyHelpful::RecordIdentifier.polymorphic_url(record, self) 
     10    end 
     11 
     12    def polymorphic_path(record) 
     13      SimplyHelpful::RecordIdentifier.polymorphic_path(record, self) 
     14    end 
     15     
    316    def redirect_to_with_record_identification(*args) 
    417      return redirect_to_without_record_identification *args unless args.size == 1 
     
    1023        redirect_to_without_record_identification *args 
    1124      else 
    12         redirect_to_without_record_identification SimplyHelpful::RecordIdentifier.named_route(potential_object, self) 
     25        redirect_to_without_record_identification SimplyHelpful::RecordIdentifier.polymorphic_url(potential_object, self) 
    1326      end 
    1427    end 
  • plugins/simply_helpful/lib/simply_helpful/form_helper_extensions.rb

    r5168 r5700  
    1919              object_name = SimplyHelpful::RecordIdentifier.singular_class_name(name_or_object) 
    2020              object      = name_or_object 
    21               url         = SimplyHelpful::RecordIdentifier.named_route(object, self) 
     21              url         = SimplyHelpful::RecordIdentifier.polymorphic_url(object, self) 
    2222           
    2323              html_options = if object.new_record? 
  • plugins/simply_helpful/lib/simply_helpful/record_identifier.rb

    r5168 r5700  
    33    extend self 
    44 
    5     def named_route(record, url_writer) 
     5    def polymorphic_url(record, url_writer) 
    66      record.new_record? ?  
    77        url_writer.send(plural_class_name(record)   + "_url") :  
    88        url_writer.send(singular_class_name(record) + "_url", record) 
     9    end 
     10 
     11    def polymorphic_path(record, url_writer) 
     12      record.new_record? ?  
     13        url_writer.send(plural_class_name(record)   + "_path") :  
     14        url_writer.send(singular_class_name(record) + "_path", record) 
    915    end 
    1016 
  • plugins/simply_helpful/lib/simply_helpful/record_tag_helper.rb

    r5308 r5700  
    6565            link_to_without_record_identification(attr_name, record, html_options, *parameters_for_method_reference) 
    6666          else 
    67             url = SimplyHelpful::RecordIdentifier.named_route(record, self) 
     67            url = SimplyHelpful::RecordIdentifier.polymorphic_url(record, self) 
    6868            link_text = record.respond_to?(attr_name) ? record.send(attr_name) : attr_name 
    6969            link_to_without_record_identification(link_text, url, html_options, *parameters_for_method_reference)