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

Changeset 6102

Show
Ignore:
Timestamp:
02/02/07 18:12:11 (1 year ago)
Author:
david
Message:

Added formatted_polymorphic_url, formatted_polymorphic_path

Files:

Legend:

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

    r6098 r6102  
    55      edit_polymorphic_url edit_polymorphic_path 
    66      new_polymorphic_url new_polymorphic_path 
     7      formatted_polymorphic_url formatted_polymorphic_path 
    78     ) 
    89     
     
    3334  end 
    3435end 
     36 
    3537module ActionController 
    3638  class Base 
  • plugins/simply_helpful/lib/simply_helpful/polymorphic_routes.rb

    r6098 r6102  
    2424    end 
    2525 
    26     def edit_polymorphic_url(record_or_hash, url_writer) 
    27       polymorphic_url(record_or_hash, url_writer, :action => "edit") 
     26    %w( edit new formatted ).each do |action| 
     27      module_eval <<-EOT 
     28        def #{action}_polymorphic_url(record_or_hash, url_writer) 
     29          polymorphic_url(record_or_hash, url_writer, :action => "#{action}") 
     30        end 
     31 
     32        def #{action}_polymorphic_path(record_or_hash, url_writer) 
     33          polymorphic_url(record_or_hash, url_writer, :action => "#{action}", :routing_type => :path) 
     34        end 
     35      EOT 
    2836    end 
    2937 
    30     def edit_polymorphic_path(record_or_hash, url_writer) 
    31       polymorphic_url(record_or_hash, url_writer, :action => "edit", :routing_type => :path) 
    32     end 
    3338 
    34     def new_polymorphic_url(record_or_hash, url_writer) 
    35       polymorphic_url(record_or_hash, url_writer, :action => "new") 
    36     end 
    37  
    38     def new_polymorphic_path(record_or_hash, url_writer) 
    39       polymorphic_url(record_or_hash, url_writer, :action => "new", :routing_type => :path) 
    40     end 
    41  
    42      
    4339    private 
    4440      def action_prefix(options)