# Dynamic content inside a view - how to do

**URL:** <https://www.ruby-forum.com/t/dynamic-content-inside-a-view-how-to-do/175998>\
**Category:** Rails\
**Created:** [September 23, 2009, 2:19pm UTC](https://www.ruby-forum.com/t/dynamic-content-inside-a-view-how-to-do/175998 "2009-09-23T14:19:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sameera](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sameera](https://www.ruby-forum.com/u/sameera)\
**Post date:** [September 23, 2009, 2:19pm UTC](https://www.ruby-forum.com/t/dynamic-content-inside-a-view-how-to-do/175998/1 "2009-09-23T14:19:09Z")

</div>

Hi,

I have a program where customer can make different conditions (sales  
promotions), I dont want to create view for each promotion for customers  
to choose.

What I thought of is, if I could save a given promotion’s view’s (html)  
code in a database and load it when user selects a give promotion

I can do it with plan HTML like,

\<%= promotion.view\_html%\>

promotion is the db object  
view\_html is the column which has the html code of the view

But when there is ruby code like loop, etc… in my html view, although  
i can save it in the database with out a problem, i cant view it

I tried to use yield, but still fails

below is my dynamic html view

\<%= @promotons = Promotion.find(:all)%\>  
\<% for promoton in @promotons %\>

- \<%= promoton.name%\>
\<%end%\>

How can i do something like this, (I hope my question is clear :)) or Am  
i doing something wrong ?!

thanks in advance

cheers  
sameera
