Skip to content

Commit

Permalink
remove piece of UrlWriter documentation claiming that you can access …
Browse files Browse the repository at this point in the history
…named routes as its class methods

This never worked: ActionController::UrlWriter.users_path
  • Loading branch information
mislav committed Mar 25, 2009
1 parent fab9d3b commit f15f1ba
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions actionpack/lib/action_controller/url_rewriter.rb
Expand Up @@ -68,29 +68,17 @@ module ActionController
# This generates, among other things, the method <tt>users_path</tt>. By default, # This generates, among other things, the method <tt>users_path</tt>. By default,
# this method is accessible from your controllers, views and mailers. If you need # this method is accessible from your controllers, views and mailers. If you need
# to access this auto-generated method from other places (such as a model), then # to access this auto-generated method from other places (such as a model), then
# you can do that in two ways. # you can do that by including ActionController::UrlWriter in your class:
#
# The first way is to include ActionController::UrlWriter in your class:
# #
# class User < ActiveRecord::Base # class User < ActiveRecord::Base
# include ActionController::UrlWriter # !!! # include ActionController::UrlWriter
# #
# def name=(value) # def base_uri
# write_attribute('name', value) # user_path(self)
# write_attribute('base_uri', users_path) # !!!
# end # end
# end # end
# #
# The second way is to access them through ActionController::UrlWriter. # User.find(1).base_uri # => "/users/1"
# The autogenerated named routes methods are available as class methods:
#
# class User < ActiveRecord::Base
# def name=(value)
# write_attribute('name', value)
# path = ActionController::UrlWriter.users_path # !!!
# write_attribute('base_uri', path) # !!!
# end
# end
module UrlWriter module UrlWriter
def self.included(base) #:nodoc: def self.included(base) #:nodoc:
ActionController::Routing::Routes.install_helpers(base) ActionController::Routing::Routes.install_helpers(base)
Expand Down

0 comments on commit f15f1ba

Please sign in to comment.