This project is archived and is in readonly mode.
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
-
Felix Sun March 19th, 2010 @ 06:39 AM
Also seems that these named routes helpers not available in action view templates, I have to do:
module ApplicationHelper include Rails.application.routes.url_helpers end
In my application, Is that should be included by default?
-
Repository March 27th, 2010 @ 08:00 AM
- State changed from new to resolved
(from [02ab7890bfe87fbd5fd3b3fba04dca9bf22255c9]) Fix a mistake in the documentation (ht: Evgeniy Dolzhenko) [#4217 state:resolved] http://github.com/rails/rails/commit/02ab7890bfe87fbd5fd3b3fba04dca...
-
Yehuda Katz (wycats) March 27th, 2010 @ 08:00 AM
- Assigned user set to Yehuda Katz (wycats)
- Milestone cleared.
The helpers should be available in views. Can you make sure this is still true on master?
-
Evgeniy Dolzhenko March 27th, 2010 @ 09:50 AM
Great, thanks!
Helpers are indeed available in views for for me.
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to Low
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>
People watching this ticket
Attachments
Referenced by
- 4217 Named routes outside of controller/view confusion (from [02ab7890bfe87fbd5fd3b3fba04dca9bf22255c9]) Fix a m...