<?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: How to use will_paginate with non-ActiveRecord collection/array</title>
	<atom:link href="http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/feed/" rel="self" type="application/rss+xml" />
	<link>http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/</link>
	<description>The Fastest Way to Launch Successful Software</description>
	<lastBuildDate>Thu, 19 Jan 2012 16:36:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Greg</title>
		<link>http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/#comment-10139</link>
		<dc:creator>Greg</dc:creator>
		<pubDate>Wed, 13 Apr 2011 19:48:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=955#comment-10139</guid>
		<description>Great post. I should have looked at the comments sooner, as I spent a bit of time before realizing that the paginate method, when called from an array, needs the params specified in a hash.</description>
		<content:encoded><![CDATA[<p>Great post. I should have looked at the comments sooner, as I spent a bit of time before realizing that the paginate method, when called from an array, needs the params specified in a hash.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt C.</title>
		<link>http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/#comment-8227</link>
		<dc:creator>Matt C.</dc:creator>
		<pubDate>Thu, 28 Oct 2010 19:58:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=955#comment-8227</guid>
		<description>Thanks for this! Honestly didn&#039;t know that will_paginate added a &#039;paginate&#039; method to Array. Cheers.</description>
		<content:encoded><![CDATA[<p>Thanks for this! Honestly didn&#8217;t know that will_paginate added a &#8216;paginate&#8217; method to Array. Cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phyo Wai Win</title>
		<link>http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/#comment-8226</link>
		<dc:creator>Phyo Wai Win</dc:creator>
		<pubDate>Wed, 18 Aug 2010 07:44:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=955#comment-8226</guid>
		<description>Thanks. Very helpful to me.</description>
		<content:encoded><![CDATA[<p>Thanks. Very helpful to me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Qza</title>
		<link>http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/#comment-8225</link>
		<dc:creator>Qza</dc:creator>
		<pubDate>Sun, 25 Apr 2010 07:43:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=955#comment-8225</guid>
		<description>u r The man. Thank you so much!</description>
		<content:encoded><![CDATA[<p>u r The man. Thank you so much!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dida</title>
		<link>http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/#comment-8224</link>
		<dc:creator>Dida</dc:creator>
		<pubDate>Fri, 16 Apr 2010 09:56:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=955#comment-8224</guid>
		<description>Nice post! I would like to run the search query to multiple models. What I understand from this post, for each model I should create a method that do the research and return it as an array. And then collect the two arrays from the models and then paginate. This means the sql query is executed for every pagination. What if the query result is huge? What is the best way to do this?

Thanks!</description>
		<content:encoded><![CDATA[<p>Nice post! I would like to run the search query to multiple models. What I understand from this post, for each model I should create a method that do the research and return it as an array. And then collect the two arrays from the models and then paginate. This means the sql query is executed for every pagination. What if the query result is huge? What is the best way to do this?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Javix</title>
		<link>http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/#comment-8223</link>
		<dc:creator>Javix</dc:creator>
		<pubDate>Mon, 30 Nov 2009 09:32:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=955#comment-8223</guid>
		<description>I can&#039;t figure out how to use the pagination with an existing array of objects got from has_many associations. So, I have Enterprise model and Service model. Enterprise has_many :services. I&#039;d like to show services for every enterprise; In my ServicesController in index action I do:
before_filter : find_client
def index
@services = @client.services
end

private
def find_client
@client = Client.find(:client_id)
end
How is it possible? If try to use like that:
@services = @client.services.paginate :page =&gt; params[:page], :order =&gt; &#039;created_at&#039;, :per_page =&gt; 20

I get:

 NoMethodError in Enterprises#show

Showing app/views/enterprises/show.html.erb where line #21 raised:

undefined method `total_pages&#039; for #

Extracted source (around line #21):

18:      &quot;/services/service&quot;,
19:       :collection =&gt; @enterprise.services, :locals=&gt; {:client =&gt; @enterprise} %&gt;
20:
21:
22:
23:
24:    &#124;</description>
		<content:encoded><![CDATA[<p>I can&#8217;t figure out how to use the pagination with an existing array of objects got from has_many associations. So, I have Enterprise model and Service model. Enterprise has_many :services. I&#8217;d like to show services for every enterprise; In my ServicesController in index action I do:<br />
before_filter : find_client<br />
def index<br />
@services = @client.services<br />
end</p>
<p>private<br />
def find_client<br />
@client = Client.find(:client_id)<br />
end<br />
How is it possible? If try to use like that:<br />
@services = @client.services.paginate :page =&gt; params[:page], <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rder =&gt; &#8216;created_at&#8217;, :per_page =&gt; 20</p>
<p>I get:</p>
<p> NoMethodError in Enterprises#show</p>
<p>Showing app/views/enterprises/show.html.erb where line #21 raised:</p>
<p>undefined method `total_pages&#8217; for #</p>
<p>Extracted source (around line #21):</p>
<p>18:      &#8220;/services/service&#8221;,<br />
19:       :collection =&gt; @enterprise.services, :locals=&gt; {:client =&gt; @enterprise} %&gt;<br />
20:<br />
21:<br />
22:<br />
23:<br />
24:    |</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amit</title>
		<link>http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/#comment-8222</link>
		<dc:creator>amit</dc:creator>
		<pubDate>Thu, 09 Apr 2009 23:32:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=955#comment-8222</guid>
		<description>Thanks works like a charm. I used the way you describe here</description>
		<content:encoded><![CDATA[<p>Thanks works like a charm. I used the way you describe here</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: s!ck</title>
		<link>http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/#comment-8221</link>
		<dc:creator>s!ck</dc:creator>
		<pubDate>Thu, 12 Feb 2009 00:41:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=955#comment-8221</guid>
		<description>hey guys, nice post. i using rails to build a client which only consumes restful webservice with activeresource, so i deactivated activerecord. i&#039;m getting an array of activeresource object limited by :page and :per_page an so on. if i try to call will_paginate @results in the view it gives me an NoMethodError. In the controller i&#039;m using that WillPaginate::Collection.create(...) and it doesn&#039;t complain. but if i activate activerecord everything works. how can i say will_paginate not to be dependent on activerecord :D do i really have to patch it myself?</description>
		<content:encoded><![CDATA[<p>hey guys, nice post. i using rails to build a client which only consumes restful webservice with activeresource, so i deactivated activerecord. i&#8217;m getting an array of activeresource object limited by :page and :per_page an so on. if i try to call will_paginate @results in the view it gives me an NoMethodError. In the controller i&#8217;m using that WillPaginate::Collection.create(&#8230;) and it doesn&#8217;t complain. but if i activate activerecord everything works. how can i say will_paginate not to be dependent on activerecord <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  do i really have to patch it myself?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shawn</title>
		<link>http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/#comment-8220</link>
		<dc:creator>shawn</dc:creator>
		<pubDate>Thu, 27 Nov 2008 01:16:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=955#comment-8220</guid>
		<description>Found it:

http://mislav.uniqpath.com/static/will_paginate/doc/

2.2.0, released 2008-04-07 API changes

Remove old, deprecated style of calling Array#paginate as &quot;paginate(page, per_page)&quot;.

If you want to specify :page, :per_page or :total_entries, use a parameter hash.</description>
		<content:encoded><![CDATA[<p>Found it:</p>
<p><a href="http://mislav.uniqpath.com/static/will_paginate/doc/" rel="nofollow">http://mislav.uniqpath.com/static/will_paginate/doc/</a></p>
<p>2.2.0, released 2008-04-07 API changes</p>
<p>Remove old, deprecated style of calling Array#paginate as &#8220;paginate(page, per_page)&#8221;.</p>
<p>If you want to specify :page, :per_page or :total_entries, use a parameter hash.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shawn</title>
		<link>http://pathfindersoftware.com/2008/06/how-to-use-will_paginate-with-non-activerecord-collectionarray/#comment-8219</link>
		<dc:creator>shawn</dc:creator>
		<pubDate>Thu, 27 Nov 2008 01:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.pathf.com/blogs/?p=955#comment-8219</guid>
		<description>Am I the only one getting the exception: Wrong number of arguments (2 for 1) trying this:

@page_results = @posts.paginate(params[:current_page], params[:per_page])

Thanks! :)</description>
		<content:encoded><![CDATA[<p>Am I the only one getting the exception: Wrong number of arguments (2 for 1) trying this:</p>
<p>@page_results = @posts.paginate(params[:current_page], params[:per_page])</p>
<p>Thanks! <img src='http://pathfindersoftware.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic (User agent is rejected)
Page Caching using memcached (User agent is rejected)

Served from: pathfindersoftware.com @ 2012-02-10 03:03:45 -->
