# Values should be filled for corresponding date, in a range

**URL:** <https://www.ruby-forum.com/t/values-should-be-filled-for-corresponding-date-in-a-range/159496>\
**Category:** Rails\
**Created:** [February 5, 2009, 3:31am UTC](https://www.ruby-forum.com/t/values-should-be-filled-for-corresponding-date-in-a-range/159496 "2009-02-05T03:31:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lookshankar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/7bcc69/32.png) [@lookshankar](https://www.ruby-forum.com/u/lookshankar)\
**Post date:** [February 5, 2009, 3:31am UTC](https://www.ruby-forum.com/t/values-should-be-filled-for-corresponding-date-in-a-range/159496/1 "2009-02-05T03:31:45Z")

</div>

Hi ,

```
I'm newbie to Rails can someone help in this.I had struck here in my

```

application and actually i solved it using PHP but don’t know how to do  
in Rails.  
I have table like this  
---------------------------------------------------------------  
|id | what | when | color | to | description |  
---------------------------------------------------------------  
|1 | test |2009-02-01 | red |2009-02-15 | yyyyy |  
---------------------------------------------------------------  
|2 | test2 |2009-02-02 | green |2009-02-14 | xxxxx |  
-----------------------------------------------------------------

i want output like this,

2009-02-01=\>\<Div id='1’style=‘color:red’\>yyyyy

2009-02-02=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-03=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-04=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-05=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-06=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-07=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-08=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-09=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-10=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-11=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-12=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-13=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-14=\>\<Div id='1’style=‘color:red’\>yyyyy  
\<Div id='2’style=‘color:green’\>xxxxx  
2009-02-15=\>\<Div id='1’style=‘color:red’\>yyyyy

## Note:

The ‘id’ of div is the value of ‘id’ field in database  
The ‘color’ of div is the value of ‘color’ field in database  
The ‘description’ of div is the value of ‘description’ field in database

can any one help in this for me…  
Thanks in advance,  
shankar.

---

<div class="post-metadata">

**Author:** ![lookshankar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/7bcc69/32.png) [@lookshankar](https://www.ruby-forum.com/u/lookshankar)\
**Post date:** [February 5, 2009, 1:59pm UTC](https://www.ruby-forum.com/t/values-should-be-filled-for-corresponding-date-in-a-range/159496/2 "2009-02-05T13:59:27Z")

</div>

On Wed, Feb 4, 2009 at 9:31 PM, Shankar G. \<  
removed\_email\_address@domain.invalid\> wrote:

> |1 | test |2009-02-01 | red |2009-02-15 | yyyyy |  
> 2009-02-03=\>\<Div id='1’style=‘color:red’\>yyyyy  
> \<Div id='2’style=‘color:green’\>xxxxx  
> 2009-02-14=\>\<Div id='1’style=‘color:red’\>yyyyy  
> How about something like:  
> \<% @records.each do |record| %\>  
> \<%= h record.when %\>  
> \<%= tag(“div”, { :id =\> record.id, :style =\> “color:#{record.color}”  
> })  
> \<% end %\>

–wpd
