# Saving Restful routes path in database

**URL:** <https://www.ruby-forum.com/t/saving-restful-routes-path-in-database/188787>\
**Category:** Rails\
**Created:** [May 18, 2010, 2:31pm UTC](https://www.ruby-forum.com/t/saving-restful-routes-path-in-database/188787 "2010-05-18T14:31:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![builtbysimple](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/aca169/32.png) [@builtbysimple](https://www.ruby-forum.com/u/builtbysimple)\
**Post date:** [May 18, 2010, 2:31pm UTC](https://www.ruby-forum.com/t/saving-restful-routes-path-in-database/188787/1 "2010-05-18T14:31:59Z")

</div>

Dear all,

I would like to save a restful resource in the database, and display  
it as a link on the web page.

I tried saving:  
bar\_path(1)  
into the path column in the table,

but unfortunately it doesn’t work when I display it like this:  
\<%= link\_to ‘bar’, bar.path %\>

Is this possible with rails?

Thank you very much in advance for your help.

## Kind regards, Joshua

[http://twitter.com/scrum8](http://twitter.com/scrum8)

–  
[http://twitter.com/scrum8](http://twitter.com/scrum8)

---

<div class="post-metadata">

**Author:** ![builtbysimple](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/aca169/32.png) [@builtbysimple](https://www.ruby-forum.com/u/builtbysimple)\
**Post date:** [May 18, 2010, 2:58pm UTC](https://www.ruby-forum.com/t/saving-restful-routes-path-in-database/188787/2 "2010-05-18T14:58:55Z")

</div>

Should be possible. When you call bar\_path(1) it just returns a string  
like “/bar/1” which you can then save in the database.

Can you clarify what “it doesn’t work” means when you try this: \<%=  
link\_to ‘bar’, bar.path %\>. Do you get an error? Does it just not  
output what you expect?

That should work for GET requests. If you wanted to link to another  
method, you’ll have to specify that since it’s not part of the path: \<  
%= link\_to ‘bar’, bar.path, :method =\> :delete %\>

---

<div class="post-metadata">

**Author:** ![builtbysimple](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/aca169/32.png) [@builtbysimple](https://www.ruby-forum.com/u/builtbysimple)\
**Post date:** [May 19, 2010, 2:02am UTC](https://www.ruby-forum.com/t/saving-restful-routes-path-in-database/188787/3 "2010-05-19T02:02:26Z")

</div>

Hi Tim,

Thank you for the response. Currently it display the plain text of the  
route method:  
bar\_path(1)

instead of:  
/bar/1

When I looked in the database it saved as String. Do I need to convert  
it into a method?

Sorry for the vague question and thanks heaps for your help.

Kind regards,  
Joshua
