Hi , I have table like this --------------------------------------------------------------- |id | what | when | color | to | description | --------------------------------------------------------------- 1 | test |2009-02-01 | red |2009-02-15 | hi this is test | --------------------------------------------------------------- 2 | test2 |2009-02-02 | green |2009-02-14 | hi this is test | --------------------------------------------------------------- -- 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 -~----------~----~----~----~------~----~------~--~---
not only that you haven''t given your post a good title ("Help me" says nothing), but you didn''t even specify your question or problem in your post. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi , 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...... -- 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 -~----------~----~----~----~------~----~------~--~---
And? Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 04/02/2009, at 9:31 PM, Shankar Ganesh <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote:> > Hi , > > I have table like this > --------------------------------------------------------------- > |id | what | when | color | to | description | > --------------------------------------------------------------- > 1 | test |2009-02-01 | red |2009-02-15 | hi this is test | > --------------------------------------------------------------- > 2 | test2 |2009-02-02 | green |2009-02-14 | hi this is test | > --------------------------------------------------------------- > -- > 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 -~----------~----~----~----~------~----~------~--~---
Please do a tutorial on rails Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 04/02/2009, at 9:42 PM, Shankar Ganesh <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote:> > Hi , > > 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...... > -- > 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 -~----------~----~----~----~------~----~------~--~---
What do you mean by "I have table like this"? is an ASCII table and you want to parse it and generate the output, or you have a table like that in your data base? On Feb 4, 10:31 am, Shankar Ganesh <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi , > > I have table like this > --------------------------------------------------------------- > |id | what | when | color | to | description | > --------------------------------------------------------------- > 1 | test |2009-02-01 | red |2009-02-15 | hi this is test | > --------------------------------------------------------------- > 2 | test2 |2009-02-02 | green |2009-02-14 | hi this is test | > --------------------------------------------------------------- > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
He means the content of his SQL table represented as ASCII was as he had it. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 05/02/2009, at 3:06 AM, Miguel Regedor <miguelregedor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > What do you mean by "I have table like this"? is an ASCII table and > you want to parse it and generate the output, or you have a table like > that in your data base? > > On Feb 4, 10:31 am, Shankar Ganesh <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> Hi , >> >> I have table like this >> --------------------------------------------------------------- >> |id | what | when | color | to | description | >> --------------------------------------------------------------- >> 1 | test |2009-02-01 | red |2009-02-15 | hi this is test | >> --------------------------------------------------------------- >> 2 | test2 |2009-02-02 | green |2009-02-14 | hi this is test | >> --------------------------------------------------------------- >> -- >> Posted viahttp://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 -~----------~----~----~----~------~----~------~--~---
Hi all, My apologies for posting a small amount of data, there was some mistake in posting this post.You can see the full post of the forum here http://www.ruby-forum.com/topic/177617#777504. Thanks for all your response. Cheers, 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 -~----------~----~----~----~------~----~------~--~---
Hi Shankar, It would help if you explained where exactly you want that kind of output. In the views? and by "2009-02-12=>" you mean the query to the DB should be based on the ''when'' field? On Feb 5, 8:33 am, Shankar Ganesh <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi all, > > My apologies for posting a small amount of data, there was some > mistake in posting this post.You can see the full post of the forum herehttp://www.ruby-forum.com/topic/177617#777504. Thanks for all your > response. > > Cheers, > Shankar. > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ram, Thanks for your help dude.Yes, I would like to have the output in the ''view'' and the value should be fetched based on ''when'' and ''to'' fields. cheers, 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 -~----------~----~----~----~------~----~------~--~---
this is really basic, basic, basic stuff. you should really read up on your basics instead of asking people to code for you. anyway, in your controller get all the entries you want to desplay: @entries = Entry.all then in your view iterate through all entries: <% for entry in @entries do %> <Div id=''<%= entry.id %>''style=''color:<%= entry.color %>''><%entry.when %></Div> <% end %> of course you could use partials as well. but as you obviously don''t know much about rails, I won''t go into that here. seriously learn some basics. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hello, This is not as regular we do for all tables.Look at the table you can see two fields ''when'' and ''to''. What I need is #1 must find the range of dates between ''when'' and ''to'' fields, #2 Then I must fill the value for each date with the corresponding values. #3 Should make an array with key as date and div content as value. Hope you got It.Anyhow thanks for reply. cheers, 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 -~----------~----~----~----~------~----~------~--~---
#1 well, if you just go like this: entry.when - entry.to you''ll get the seconds in between both times. you can then calculate minutes, hours, days, ... #2 filling in the values should then be a piece of cake. #3 what you are looking for is not an array, but a hash. shouldn''t be problem, once you''ve figured out how to write some ruby-code. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Can you explain with a bit of code, It will be helpful for me apologizes I''m newbie to ROR and I''m a PHP developer.I would like to develop calendar using ROR when I am ti display the events I got struck here. -- 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 -~----------~----~----~----~------~----~------~--~---
i''m still not sure, what exactly you are trying to do, but try something like this: # create hash hash = Hash.new # iterate through your entries for entry in @entries do # create date date = entry.when.to_date # calculate range in days days = ((entry.to - entry.when)/86400).round) # for every day add a value to hash days.times do # build the string string = "<Div id=''1'' style=''color:" + entry.color + "''>" + entry.description + "</Div>" if hash.has_key?(date) # append string string = hash[date] + string end # add to hash hash.merge!({date => string}) # increase date date = date.advance(:days => 1) end end # iterate through your hash hash.each_pair do |key, value| # output puts key + ''=>'' + value end i should mention a few things: 1) i did this because i was bored. for the future, try it on your own and ask if you are stuck. post your code, so people can spot the error for you. don''t expect people to code for you. 2) i did not test the code above. i just hacked it into this post. there may be errors in it. 3) your page will not work with all the divs having the same id. id should be unique, but as php-coder you should already know that... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ya thanks for your post, hope it will be helpful. -- 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 -~----------~----~----~----~------~----~------~--~---
You don''t need a do when you''re using for in Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 05/02/2009, at 5:59 PM, MaD <mayer.dominik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > this is really basic, basic, basic stuff. you should really read up on > your basics instead of asking people to code for you. > > anyway, in your controller get all the entries you want to desplay: > @entries = Entry.all > > then in your view iterate through all entries: > <% for entry in @entries do %> > <Div id=''<%= entry.id %>''style=''color:<%= entry.color %>''><%> entry.when %></Div> > <% end %> > > of course you could use partials as well. but as you obviously don''t > know much about rails, I won''t go into that here. seriously learn some > basics. > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Arrays do not have keys and values. Ruby is not php. An orderedhash is like a php associative array. Your description of your problem is not clear enough. Ask simple clear questions and we can help then. You seem to be having algorhithm problems, not language problems. Explain your algorhithm to us on pseudocode and show the ruby you''ve tried and then we will help where you''re stuck. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 05/02/2009, at 6:07 PM, Shankar Ganesh <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote:> > Hello, > > This is not as regular we do for all tables.Look at the table you > can see two fields ''when'' and ''to''. What I need is > > #1 must find the range of dates between ''when'' and ''to'' fields, > #2 Then I must fill the value for each date with the corresponding > values. > #3 Should make an array with key as date and div content as value. > > Hope you got It.Anyhow thanks for reply. > > cheers, > 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 -~----------~----~----~----~------~----~------~--~---
Nah, he has string fields Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 05/02/2009, at 6:21 PM, MaD <mayer.dominik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > #1 > well, if you just go like this: > entry.when - entry.to > you''ll get the seconds in between both times. you can then calculate > minutes, hours, days, ... > > #2 > filling in the values should then be a piece of cake. > > #3 > what you are looking for is not an array, but a hash. shouldn''t be > problem, once you''ve figured out how to write some ruby-code. > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Your English Has confusions! Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 05/02/2009, at 6:27 PM, Shankar Ganesh <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote:> > Can you explain with a bit of code, It will be helpful for me > apologizes > I''m newbie to ROR and I''m a PHP developer.I would like to develop > calendar using ROR when I am ti display the events I got struck here. > -- > 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 -~----------~----~----~----~------~----~------~--~---
For...in doesn''t take do! Obviously you''re not testing your code before you suggest it!!! Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 05/02/2009, at 7:08 PM, MaD <mayer.dominik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > i''m still not sure, what exactly you are trying to do, but try > something like this: > > # create hash > hash = Hash.new > # iterate through your entries > for entry in @entries do > # create date > date = entry.when.to_date > # calculate range in days > days = ((entry.to - entry.when)/86400).round) > # for every day add a value to hash > days.times do > # build the string > string = "<Div id=''1'' style=''color:" + entry.color + "''>" + > entry.description + "</Div>" > if hash.has_key?(date) > # append string > string = hash[date] + string > end > # add to hash > hash.merge!({date => string}) > # increase date > date = date.advance(:days => 1) > end > end > > # iterate through your hash > hash.each_pair do |key, value| > # output > puts key + ''=>'' + value > end > > i should mention a few things: > 1) i did this because i was bored. for the future, try it on your own > and ask if you are stuck. post your code, so people can spot the error > for you. don''t expect people to code for you. > 2) i did not test the code above. i just hacked it into this post. > there may be errors in it. > 3) your page will not work with all the divs having the same id. id > should be unique, but as php-coder you should already know that... > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
hallo julian, you already said the following:> You don''t need a do when you''re using for inyou''re right on that one, but you don''t have to tell me twice:> For...in doesn''t take do!especially as this is just wrong. try it yourself: for number in [1, 2, 3] do puts number end> Obviously you''re not testing your code before you suggest it!!!i already said that:> i should mention a few things: > 2) i did not test the code above. i just hacked it into this post. > there may be errors in it.so: obviously you''re not reading a post before you comment on it! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You''re right I skim them. Sorry about that. Didn''t realize you could use do there. It''s definitely optional tho. I fail :) thanks, I learn something. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 06/02/2009, at 10:58 PM, MaD <mayer.dominik-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > hallo julian, > > you already said the following: >> You don''t need a do when you''re using for in > you''re right on that one, but you don''t have to tell me twice: >> For...in doesn''t take do! > especially as this is just wrong. try it yourself: > for number in [1, 2, 3] do > puts number > end > > >> Obviously you''re not testing your code before you suggest it!!! > i already said that: >> i should mention a few things: >> 2) i did not test the code above. i just hacked it into this post. >> there may be errors in it. > so: obviously you''re not reading a post before you comment on it! > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---