<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kwølf &#187; Rails</title>
	<atom:link href="http://kw0lf.org/blog/archives/tag/rails/feed" rel="self" type="application/rss+xml" />
	<link>http://kw0lf.org/blog</link>
	<description>Walking on water and developing software from a specification are easy if both are frozen</description>
	<lastBuildDate>Fri, 24 Sep 2010 03:50:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Paginación en RoR</title>
		<link>http://kw0lf.org/blog/archives/200</link>
		<comments>http://kw0lf.org/blog/archives/200#comments</comments>
		<pubDate>Sat, 12 Jun 2010 19:28:17 +0000</pubDate>
		<dc:creator>kw0lf</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">http://kw0lf.org/blog/?p=200</guid>
		<description><![CDATA[La forma mas simple de hacer paginacion de resultados en rails es la siguiente(actualmente estoy usando Ruby on Rails 2.3.8 y RubyGem 1.3.7) Instalar la gema mislav-will_paginate sudo gem source -a http://gems.github.com; sudo gem install mislav-will_paginate Agregar la gema a tu archivo enviroment.rb => /config/enviroment.rb config.gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com' Agregar el [...]]]></description>
			<content:encoded><![CDATA[<p>La forma mas simple de hacer paginacion de resultados en rails es la siguiente(actualmente estoy usando Ruby on Rails 2.3.8 y RubyGem 1.3.7)</p>
<li>Instalar la gema mislav-will_paginate</li>
<pre name="code" class="ruby">
sudo gem source -a http://gems.github.com; sudo gem install mislav-will_paginate</pre>
<li>Agregar la gema a tu archivo  enviroment.rb => /config/enviroment.rb</li>
<pre name="code" class="ruby">config.gem 'mislav-will_paginate', :lib => 'will_paginate', :source => 'http://gems.github.com'</pre>
<li>Agregar el metodo para paginar al controlador </li>
<pre name="code" class="ruby"> def index
   @personas = Persona.paginate(:per_page => 5, :page => params[:page])
  end</pre>
<p> En este caso se esta exigiendo una paginacion cada 5 resultados , ud puede/debe cambiar el numero de  resultados que desea por pagina.</p>
<li>Agregar la paginacion a nuestra vista.</li>
<pre name="code" class="ruby">  will_paginate @personas, :prev_label => "&laquo; Anterior", :next_label=> "Siguiente &raquo;" </pre>
<p>Si deseas que tu paginacion  use ajax agregue lo siguiente .</p>
<li>Crear el archivo index.js.erb  en la carperta de tus vistas y colocar el siguiente codigo dentro de el:</li>
<pre name="code" class="ruby">"#personas_url").html("<%= escape_javascript(render("personas")) %>");</pre>
<li>Crear el archivo  pagination.js dentro de /public/javascripts e insertarle este codigo:</li>
<pre name="code" class="ruby">$(function() {
  $(".pagination a").live("click", function() {
    $(".pagination").html("Cargando pagina...");
    $.get(this.href, null, null, "script");
    return false;
  });
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://kw0lf.org/blog/archives/200/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

