app/models/blog.rb
def url_for(options = {}, *extra_params)
    case options
    when String then options # They asked for 'url_for "/some/path"', so return it unedited.
    when Hash
      unless RouteCache[options]
        options.reverse_merge!(:only_path => true, :controller => '',
                               :action => 'permalink')
        @url ||= ActionController::UrlRewriter.new(BlogRequest.new(self.base_url), {})
        RouteCache[options] = @url.rewrite(options)
      end

      return RouteCache[options]
    else
      raise "Invalid URL in url_for: #{options.inspect}"
    end
  end
# Generate a URL based on the +base_url+.  This allows us to generate URLs
# without needing a controller handy, so we can produce URLs from within models
# where appropriate.
#
# It also uses our new RouteCache, so repeated URL generation requests should be
# fast, as they bypass all of Rails' route logic.
Generate a URL based on the +base_url+.  This allows us to generate URLs
without needing a controller handy, so we can produce URLs from within models
where appropriate.

It also uses our new RouteCache, so repeated URL generation requests should be
fast, as they bypass all of Rails' route logic.
Generate a URL based on the + base_url + . This allows us to generate URLs without needing a controller handy so we can produce URLs from within models where appropriate . It also uses our new RouteCache so repeated URL generation requests should be fast as they bypass all of Rails ' route logic .
def url_for(options = {}, *extra_params)
    case options
    when String then options 
    when Hash
      unless RouteCache[options]
        options.reverse_merge!(:only_path => true, :controller => '',
                               :action => 'permalink')
        @url ||= ActionController::UrlRewriter.new(BlogRequest.new(self.base_url), {})
        RouteCache[options] = @url.rewrite(options)
      end
      return RouteCache[options]
    else
      raise "Invalid URL in url_for: #{options.inspect}"
    end
  end
def url_for ( options = { } , * extra_params ) case options when String then options when Hash unless RouteCache [ options ] options . reverse_merge! ( :only_path => true , :controller => '' , :action => 'permalink' ) @url ||= ActionController :: UrlRewriter . new ( BlogRequest . new ( self . base_url ) , { } ) RouteCache [ options ] = @url . rewrite ( options ) end return RouteCache [ options ] else raise "Invalid URL in url_for: #{options.inspect}" end end
Generate a URL based on the +base_url+.
Generate a URL based on the + base_url + .
# They asked for 'url_for "/some/path"', so return it unedited.
options
extra_params