Hello there, I started with to_set.classify and have the find function grouping by day. I then did a group_by function to the same effect both in the model and the view. They both work wonderfully except I need to pull the full date from it not just the number of the day. controller @groups = Lineup.find(:all, :conditions => search_conditions, :limit => 400, :include => [{:event => :venue}, {:artist => :genre}, :artist]).to_set.classify {|lineup| lineup.event.event_time.day}.sort In the view I have two loops set to run through the day then the lineups. strftime will not work since it is a fix num but I need the month of the day and the name of the day. Any ideas? Thanks for your help! Best, Jackson --~--~---------~--~----~------------~-------~--~----~ 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 have it pulling using a method that I created in the model. def day self.event.event_time.strftime("%B%d%A") end That spits out the string that I require then I parse it with reg ex and match. In the view I have: <% @groups.group_by(&:day).each do |day, lineups| %> Now the problem is sorting. If I sort in the view, I''m sorting by strings. In the controller: @groups = Lineup.find(:all, :conditions => search_conditions, :limit => 400, :include => [{:event => :venue}, {:artist => :genre}, :artist]).sort_by{|e| e.event.event_time} I can sort by time but it only sorts the individual lineups, the group by day seems to be unaffected. Dates are fun... Can anyone provide some direction? Thanks, Jackson On Jul 29, 2:16 am, Jackson <jhblackl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello there, > > I started with to_set.classify and have the find function grouping by > day. I then did a group_by function to the same effect both in the > model and the view. > > They both work wonderfully except I need to pull the full date from it > not just the number of the day. > > controller > > @groups = Lineup.find(:all, :conditions => search_conditions, :limit > => 400, :include => [{:event => :venue}, {:artist > => :genre}, :artist]).to_set.classify {|lineup| > lineup.event.event_time.day}.sort > > In the view I have two loops set to run through the day then the > lineups. > > strftime will not work since it is a fix num but I need the month of > the day and the name of the day. > > Any ideas? Thanks for your help! > > Best, > > Jackson--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
def day self.event.event_time.strftime("%y%j%d%B%A") end This will sort by year to account for January then the day number. On Jul 29, 2:16 am, Jackson <jhblackl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello there, > > I started with to_set.classify and have the find function grouping by > day. I then did a group_by function to the same effect both in the > model and the view. > > They both work wonderfully except I need to pull the full date from it > not just the number of the day. > > controller > > @groups = Lineup.find(:all, :conditions => search_conditions, :limit > => 400, :include => [{:event => :venue}, {:artist > => :genre}, :artist]).to_set.classify {|lineup| > lineup.event.event_time.day}.sort > > In the view I have two loops set to run through the day then the > lineups. > > strftime will not work since it is a fix num but I need the month of > the day and the name of the day. > > Any ideas? Thanks for your help! > > Best, > > Jackson--~--~---------~--~----~------------~-------~--~----~ 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 do have the same question, did you find any answer ? thanks On 29 juil, 08:16, Jackson <jhblackl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello there, > > I started with to_set.classify and have the find function grouping by > day. I then did a group_by function to the same effect both in the > model and the view. > > They both work wonderfully except I need to pull the full date from it > not just the number of the day. > > controller > > @groups = Lineup.find(:all, :conditions => search_conditions, :limit > => 400, :include => [{:event => :venue}, {:artist > => :genre}, :artist]).to_set.classify {|lineup| > lineup.event.event_time.day}.sort > > In the view I have two loops set to run through the day then the > lineups. > > strftime will not work since it is a fix num but I need the month of > the day and the name of the day. > > Any ideas? Thanks for your help! > > Best, > > Jackson--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yeah, Went well! controller:: @groups = Lineup.find(:all, :conditions => search_conditions, :limit => 400, :include => [{:event => :venue}, {:artist => :genre}, :artist]).sort_by{|e| e.event.event_time} model:: def day self.event.event_time.strftime("%y%j%d%B%A") end view:: <% @groups.group_by(&:day).sort.each do |day, lineups| %> <%= day.match(''((?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?| May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:t|ember)?|Oct(?:ober)?| Nov(?:ember)?|Dec(?:ember)?))'').to_s.upcase %> <repeat with="&lineups.sort_by{|lineup| lineup.event.event_time}"> <%= this.event.event_time.strftime("%I" + ":" + "%M%p") %> </repeat> <% end %> The second repeat is hobo dryml but it should make sense. The controller call sorts every return. The model''s definition was key. I had to find all by day using the strftime function but needed more info than just the day number. I put month, day, day full name. That was tough to sort because you trade in the datetime class for a string, I added year then day of the year so the records would come back in order. The view I pulled the substrings using regex matches. (http://txt2re.com/) I hope this helps. Let me know if you have any questions, I''ll see what I can do. Best, Jackson On Jul 30, 6:18 am, Differenthink <guillaume.mont...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I do have the same question, did you find any answer ? > > thanks > > On 29 juil, 08:16, Jackson <jhblackl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello there, > > > I started with to_set.classify and have the find function grouping by > > day. I then did a group_by function to the same effect both in the > > model and the view. > > > They both work wonderfully except I need to pull the full date from it > > not just the number of the day. > > > controller > > > @groups = Lineup.find(:all, :conditions => search_conditions, :limit > > => 400, :include => [{:event => :venue}, {:artist > > => :genre}, :artist]).to_set.classify {|lineup| > > lineup.event.event_time.day}.sort > > > In the view I have two loops set to run through the day then the > > lineups. > > > strftime will not work since it is a fix num but I need the month of > > the day and the name of the day. > > > Any ideas? Thanks for your help! > > > Best, > > > Jackson--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---