Forum: Ruby on Rails Using named routes in a model

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B79f6edafee26860eb2ef239558bf8dc?d=identicon&s=25 Lee Pope (Guest)
on 2005-12-12 01:42
(Received via mailing list)
I have searched this list for an answer, can't find one.

Does anybody know a way to use named routes (or url_for, if need be) to
generate a url that i can use for a Model? The generated convenience
methods, even url_for itself, seem to only be available in
ActionController
and ActionView.

Thanks,

Lee
--
*********************************

All that is gold does not glitter.
Not all those who wander are lost.
The old who are strong do not whither.
Deep roots are not touched by the frost.
                     -- J.R.R. Tolkein
01d7a451018ac15518f425078ef00c40?d=identicon&s=25 Phillip Hutchings (Guest)
on 2005-12-12 01:45
(Received via mailing list)
On 12/12/2005, at 1:39 PM, Lee Pope wrote:

> Does anybody know a way to use named routes (or url_for, if need
> be) to generate a url that i can use for a Model? The generated
> convenience methods, even url_for itself, seem to only be available
> in ActionController and ActionView.

That is quite right, because models aren't supposed to know about
URLs. Models encapsulate business rules, URLs are controller/view
elements. What you probably want is a helper.

--
Phillip Hutchings
phillip.hutchings@sitharus.com
This topic is locked and can not be replied to.