This project is archived and is in readonly mode.

#4217 ✓resolved
Evgeniy Dolzhenko

Named routes outside of controller/view confusion

Reported by Evgeniy Dolzhenko | March 18th, 2010 @ 05:01 PM | in 3.0.2

Here is quote from http://github.com/rails/rails/blob/master/actionpack/lib/action_dis...

    # 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
    # to access this auto-generated method from other places (such as a model), then
    # you can do that by including ActionController::UrlFor in your class:
    #
    #   class User < ActiveRecord::Base
    #     include ActionController::UrlFor
    #
    #     def base_uri
    #       user_path(self)
    #     end
    #   end

This currently doesn't work, in contrast include Rails.application.routes.url_helpers does,
but is it the proper way to get routes generated outside of controller/view?

In any case docs is wrong on that one, attached patch which demonstrates
the change.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages