# How to embed a route url inside of a helper, to return a pat

**URL:** <https://www.ruby-forum.com/t/how-to-embed-a-route-url-inside-of-a-helper-to-return-a-pat/113444>\
**Category:** Rails\
**Created:** [August 31, 2007, 2:50am UTC](https://www.ruby-forum.com/t/how-to-embed-a-route-url-inside-of-a-helper-to-return-a-pat/113444 "2007-08-31T02:50:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arachnd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/278dde/32.png) [@arachnd](https://www.ruby-forum.com/u/arachnd)\
**Post date:** [August 31, 2007, 2:50am UTC](https://www.ruby-forum.com/t/how-to-embed-a-route-url-inside-of-a-helper-to-return-a-pat/113444/1 "2007-08-31T02:50:13Z")

</div>

I am creating custom link\_to’s and I’m trying to figure out how to  
embed a path inside of my method to return a custom link.

for e.g

Let’s say I need to do this =\>

“[SomeAPi.com is for sale | HugeDomains](http://someapi.com/submit?key=value&key=value&url=path_to_object)”

path\_to\_object should return something like ‘[www.mysite.com/path/to/](http://www.mysite.com/path/to/)  
object’

I tried to do something like content\_tag :a do, etc… and I got to the  
point where I got this =\>

link\_to\_api(user)

“[HugeDomains.com](http://someapi.com/submit?key=value&key=value&url=user_path)”

What I found out was that user\_path doesn’t get evaluated into an  
actual path like it does in a controller, or a view. So how would I  
actually turn ‘user\_path’ into the proper path that routes takes care  
of? (same functionality as link\_to I guess).

Thanks!

---

<div class="post-metadata">

**Author:** ![arachnd](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/278dde/32.png) [@arachnd](https://www.ruby-forum.com/u/arachnd)\
**Post date:** [September 1, 2007, 2:27am UTC](https://www.ruby-forum.com/t/how-to-embed-a-route-url-inside-of-a-helper-to-return-a-pat/113444/2 "2007-09-01T02:27:54Z")

</div>

[DanielFischer.com](http://DanielFischer.com) wrote:

> path\_to\_object should return something like '[www.mysite.com/path/to/](http://www.mysite.com/path/to/)  
> actual path like it does in a controller, or a view. So how would I  
> actually turn ‘user\_path’ into the proper path that routes takes care  
> of? (same functionality as link\_to I guess).
> 
> Thanks!

Take a look at url\_for.

–  
Michael W.
