# Embedding link\_to's as part of rendered text

**URL:** <https://www.ruby-forum.com/t/embedding-link-tos-as-part-of-rendered-text/62086>\
**Category:** Rails\
**Created:** [May 31, 2006, 12:48pm UTC](https://www.ruby-forum.com/t/embedding-link-tos-as-part-of-rendered-text/62086 "2006-05-31T12:48:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![samonderous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@samonderous](https://www.ruby-forum.com/u/samonderous)\
**Post date:** [May 31, 2006, 12:48pm UTC](https://www.ruby-forum.com/t/embedding-link-tos-as-part-of-rendered-text/62086/1 "2006-05-31T12:48:33Z")

</div>

Hi,

I’d like to be able to do a database query, fetch some text, and add an  
‘Accept Request’ and ‘Deny Request’ within the text. Both of these  
would be  
links so if the user were to click on them, they would essentially send  
POST  
requests back to the server. Since this is dynamic, I wanted to know  
the  
safest/best approach in embedding these links within fetched text coming  
from a query?

Should I embed the ‘link\_to(“Accept Request”…)’ in the text before  
saving  
it in the database, so that when it gets fetched, the view should  
automatically parse that and see a link\_to? Or, are there other ways.

Thanks.

---

<div class="post-metadata">

**Author:** ![samonderous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/3da27b/32.png) [@samonderous](https://www.ruby-forum.com/u/samonderous)\
**Post date:** [May 31, 2006, 2:15pm UTC](https://www.ruby-forum.com/t/embedding-link-tos-as-part-of-rendered-text/62086/2 "2006-05-31T14:15:17Z")

</div>

If you want to embed the link\_to in the database, you’ll need to render  
it inside of a controller. This seems like the best way to avoid “hard  
coding the links”. I’ve tried my hardest to produce a plugin that would  
render text held within \<view tags, but it appears that rails is  
setup in a way that makes this nearly impossible.

On Wed, 2006-05-31 at 03:46 -0700, Sam D. wrote:

> saving it in the database, so that when it gets fetched, the view  
> should automatically parse that and see a link\_to? Or, are there  
> other ways.
> 
> Thanks.
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Charlie B.  
[http://www.recentrambles.com](http://www.recentrambles.com)
