<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Rails: Group results by week (using group_by)</title> <atom:link href="http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/feed/" rel="self" type="application/rss+xml" /><link>http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/</link> <description>Code Monkey</description> <lastBuildDate>Thu, 11 Mar 2010 04:50:50 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>By: Casper Kaandorp</title><link>http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/comment-page-1/#comment-11447</link> <dc:creator>Casper Kaandorp</dc:creator> <pubDate>Thu, 21 Jan 2010 16:45:11 +0000</pubDate> <guid
isPermaLink="false">http://beta.ariejan.net/?p=70#comment-11447</guid> <description>Kom ik je idd nog even tegen!</description> <content:encoded><![CDATA[<p>Kom ik je idd nog even tegen!</p> ]]></content:encoded> </item> <item><title>By: flunder</title><link>http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/comment-page-1/#comment-11415</link> <dc:creator>flunder</dc:creator> <pubDate>Mon, 11 Jan 2010 01:47:17 +0000</pubDate> <guid
isPermaLink="false">http://beta.ariejan.net/?p=70#comment-11415</guid> <description>No problems here with pagination nor color scheme, just a thanks for this as it saved me alot of time!</description> <content:encoded><![CDATA[<p>No problems here with pagination nor color scheme, just a thanks for this as it saved me alot of time!</p> ]]></content:encoded> </item> <item><title>By: mech</title><link>http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/comment-page-1/#comment-10857</link> <dc:creator>mech</dc:creator> <pubDate>Wed, 19 Aug 2009 03:39:18 +0000</pubDate> <guid
isPermaLink="false">http://beta.ariejan.net/?p=70#comment-10857</guid> <description>Problem is how do you deal with pagination with will_paginate? When u use the group_by from Enumerable, it cannot do a proper pagination</description> <content:encoded><![CDATA[<p>Problem is how do you deal with pagination with will_paginate? When u use the group_by from Enumerable, it cannot do a proper pagination</p> ]]></content:encoded> </item> <item><title>By: Shaun</title><link>http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/comment-page-1/#comment-10732</link> <dc:creator>Shaun</dc:creator> <pubDate>Tue, 12 May 2009 03:52:43 +0000</pubDate> <guid
isPermaLink="false">http://beta.ariejan.net/?p=70#comment-10732</guid> <description>Great post! Only problem is your color scheme.  Purple on gray is not readable.</description> <content:encoded><![CDATA[<p>Great post! Only problem is your color scheme.  Purple on gray is not readable.</p> ]]></content:encoded> </item> <item><title>By: Tillmann Carlos Bielefeld</title><link>http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/comment-page-1/#comment-10715</link> <dc:creator>Tillmann Carlos Bielefeld</dc:creator> <pubDate>Thu, 12 Mar 2009 09:53:41 +0000</pubDate> <guid
isPermaLink="false">http://beta.ariejan.net/?p=70#comment-10715</guid> <description>Thank you, man! eventize.de now groups events. Cheers!</description> <content:encoded><![CDATA[<p>Thank you, man! eventize.de now groups events. Cheers!</p> ]]></content:encoded> </item> <item><title>By: Victor</title><link>http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/comment-page-1/#comment-10630</link> <dc:creator>Victor</dc:creator> <pubDate>Sun, 09 Nov 2008 04:52:44 +0000</pubDate> <guid
isPermaLink="false">http://beta.ariejan.net/?p=70#comment-10630</guid> <description>@items.keys.sort.each do &#124;release_date&#124;</description> <content:encoded><![CDATA[<p>@items.keys.sort.each do |release_date|</p> ]]></content:encoded> </item> <item><title>By: Victor</title><link>http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/comment-page-1/#comment-10629</link> <dc:creator>Victor</dc:creator> <pubDate>Sun, 09 Nov 2008 04:52:08 +0000</pubDate> <guid
isPermaLink="false">http://beta.ariejan.net/?p=70#comment-10629</guid> <description>Whoops, forgot to add the view code: </description> <content:encoded><![CDATA[<p>Whoops, forgot to add the view code:</p> ]]></content:encoded> </item> <item><title>By: Victor</title><link>http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/comment-page-1/#comment-10628</link> <dc:creator>Victor</dc:creator> <pubDate>Sun, 09 Nov 2008 04:51:26 +0000</pubDate> <guid
isPermaLink="false">http://beta.ariejan.net/?p=70#comment-10628</guid> <description>How about if you want to group_by one attribute  but you want to sort the resultant groups by another attribute of the object?i.e., I am grouping by the distance_of_time_in_words value of the release_date attribute but when I sort the resultant hash, everything&#039;s sorted alphabetically (i.e. instead of &quot;6 Days &quot;, &quot;5 Weeks&quot;, &quot;1 Month&quot;, &quot;4 Months&quot; I get &quot;1 Month&quot;, &quot;4 Months&quot;, &quot;5 Weeks&quot;, &quot;6 Days&quot;)Here&#039;s some of my code:
Controller:
@items = Category.all_category_items.group_by {&#124;i&#124; distance_of_time_in_words(Time.now, i.release_date)}View:This gives me the alphabetical order.How do I sort by the first @item.release_date in the group instead of the distance_of_time_in_words(Time.now, i.release_date) but still group by distance_of_time_in_words(Time.now, i.release_date)?</description> <content:encoded><![CDATA[<p>How about if you want to group_by one attribute  but you want to sort the resultant groups by another attribute of the object?</p><p>i.e., I am grouping by the distance_of_time_in_words value of the release_date attribute but when I sort the resultant hash, everything&#8217;s sorted alphabetically (i.e. instead of &#8220;6 Days &#8220;, &#8220;5 Weeks&#8221;, &#8220;1 Month&#8221;, &#8220;4 Months&#8221; I get &#8220;1 Month&#8221;, &#8220;4 Months&#8221;, &#8220;5 Weeks&#8221;, &#8220;6 Days&#8221;)</p><p>Here&#8217;s some of my code:<br
/> Controller:<br
/> @items = Category.all_category_items.group_by {|i| distance_of_time_in_words(Time.now, i.release_date)}</p><p>View:</p><p>This gives me the alphabetical order.</p><p>How do I sort by the first @item.release_date in the group instead of the distance_of_time_in_words(Time.now, i.release_date) but still group by distance_of_time_in_words(Time.now, i.release_date)?</p> ]]></content:encoded> </item> <item><title>By: Christian</title><link>http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/comment-page-1/#comment-10521</link> <dc:creator>Christian</dc:creator> <pubDate>Wed, 07 May 2008 23:45:59 +0000</pubDate> <guid
isPermaLink="false">http://beta.ariejan.net/?p=70#comment-10521</guid> <description>Ah ha! I found that (for me at least) this:
Week
&#039;post&#039;, :collection =&gt; @posts %&gt;should read:
Week
&#039;post&#039;, :collection =&gt; posts %&gt;*the @ symbol should be removed from &#039;:collection =&gt; @posts&#039;This solved my problem of getting repeating posts. It seems that the collection should be of the local variable posts rather than the instance variable of @post (which contains all of the entries in the database)</description> <content:encoded><![CDATA[<p>Ah ha! I found that (for me at least) this:</p><p> Week<br
/> &#8216;post&#8217;, :collection =&gt; @posts %&gt;</p><p>should read:</p><p> Week<br
/> &#8216;post&#8217;, :collection =&gt; posts %&gt;</p><p>*the @ symbol should be removed from &#8216;:collection =&gt; @posts&#8217;</p><p>This solved my problem of getting repeating posts. It seems that the collection should be of the local variable posts rather than the instance variable of @post (which contains all of the entries in the database)</p> ]]></content:encoded> </item> <item><title>By: Christian</title><link>http://ariejan.net/2007/01/12/rails-group-results-by-week-using-group_by/comment-page-1/#comment-10520</link> <dc:creator>Christian</dc:creator> <pubDate>Wed, 07 May 2008 23:25:07 +0000</pubDate> <guid
isPermaLink="false">http://beta.ariejan.net/?p=70#comment-10520</guid> <description>I&#039;m having the same issue, I get it broken up nicely by week, but each post is listed under each week. ie 3 weeks = triple the posts.</description> <content:encoded><![CDATA[<p>I&#8217;m having the same issue, I get it broken up nicely by week, but each post is listed under each week. ie 3 weeks = triple the posts.</p> ]]></content:encoded> </item> </channel> </rss>
<!-- This site's performance optimized by W3 Total Cache. Dramatically improve the speed and reliability of your blog!

Learn more about our WordPress Plugins: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached (user agent is rejected)

Served from: starbuck.ariejan.net @ 2010-03-12 15:48:21 -->