I want to construct a time period, i.e. say a user has 1 month, 3 days and 10 hours to do something. I want to store this information in a database, and instead of storing this information in 3 fields, I want to store it in one. I have 3 select boxes, one for Month, Days, and Hours, and I''m using "before_save" to convert the selected value into seconds. However, when I retrieve the information from the database what would be the best way to retrieve the Month, Days and Hours information again? Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Store it as a datetime field and then use distance_of_time_in_words to work out how long the user has to do it. On Dec 17, 2007 9:44 AM, Luke Grimstrup <luke.g-kXw2iXeozmoY+eTVAdjFZg@public.gmane.org> wrote:> > I want to construct a time period, i.e. say a user has 1 month, 3 days > and 10 hours to do something. I want to store this information in a > database, and instead of storing this information in 3 fields, I want > to store it in one. > I have 3 select boxes, one for Month, Days, and Hours, and I''m using > "before_save" to convert the selected value into seconds. > > However, when I retrieve the information from the database what would > be the best way to retrieve the Month, Days and Hours information > again? > > Thanks in advance. > > >-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
or you could read my other reply here: http://railsforum.com/viewtopic.php?pid=48008#p48008 On Dec 17, 2007 10:12 AM, Ryan Bigg <radarlistener-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Store it as a datetime field and then use distance_of_time_in_words to > work out how long the user has to do it. > > > On Dec 17, 2007 9:44 AM, Luke Grimstrup < luke.g-kXw2iXeozmoY+eTVAdjFZg@public.gmane.org> wrote: > > > > > I want to construct a time period, i.e. say a user has 1 month, 3 days > > and 10 hours to do something. I want to store this information in a > > database, and instead of storing this information in 3 fields, I want > > to store it in one. > > I have 3 select boxes, one for Month, Days, and Hours, and I''m using > > "before_save" to convert the selected value into seconds. > > > > However, when I retrieve the information from the database what would > > be the best way to retrieve the Month, Days and Hours information > > again? > > > > Thanks in advance. > > > > > > > > > -- > Ryan Bigg > http://www.frozenplague.net-- Ryan Bigg http://www.frozenplague.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---