Shankar Ganesh
2009-Feb-05 02:31 UTC
Values should be filled for corresponding date, in a range.
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</Div> 2009-02-02=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-03=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-04=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-05=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-06=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-07=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-08=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-09=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-10=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-11=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-12=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-13=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-14=><Div id=''1''style=''color:red''>yyyyy</Div> <Div id=''2''style=''color:green''>xxxxx</Div> 2009-02-15=><Div id=''1''style=''color:red''>yyyyy</Div> 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Patrick Doyle
2009-Feb-05 12:58 UTC
Re: Values should be filled for corresponding date, in a range.
On Wed, Feb 4, 2009 at 9:31 PM, Shankar Ganesh < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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</Div> > > 2009-02-02=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-03=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-04=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-05=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-06=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-07=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-08=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-09=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-10=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-11=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-12=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-13=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-14=><Div id=''1''style=''color:red''>yyyyy</Div> > <Div id=''2''style=''color:green''>xxxxx</Div> > 2009-02-15=><Div id=''1''style=''color:red''>yyyyy</Div> > > 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 > > > How about something like:<% @records.each do |record| %> <%= h record.when %> <%= tag("div", { :id => record.id, :style => "color:#{record.color}" }) <% end %> --wpd --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---