How to embed a route url inside of a helper, to return a path?

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 =>

"http://someapi.com/submit?key=value&key=value&url=path_to_object"

path_to_object should return something like '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)

"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!

DanielFischer.com wrote:

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 =>

"http://someapi.com/submit?key=value&key=value&url=path_to_object"

path_to_object should return something like '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)

"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!

Take a look at url_for.