<?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>metaduck &#187; Ruby</title>
	<atom:link href="http://www.metaduck.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.metaduck.com</link>
	<description></description>
	<lastBuildDate>Wed, 05 May 2010 12:04:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Will_paginate and AJAX</title>
		<link>http://www.metaduck.com/2010/04/will_paginate-and-ajax/</link>
		<comments>http://www.metaduck.com/2010/04/will_paginate-and-ajax/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 15:07:59 +0000</pubDate>
		<dc:creator>Pedro Teixeira</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.metaduck.com/?p=247</guid>
		<description><![CDATA[I have been using will_paginate ever since I started on Rails.
It's a great plugin for classic page rendering, but what if you want to use it with AJAX, so it updates a document element (a floating window layer, for instance) with the results instead of reloading the page?
Well, inspired on Redline's blog post (which almost [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using will_paginate ever since I started on Rails.</p>
<p>It's a great plugin for classic page rendering, but what if you want to use it with AJAX, so it updates a document element (a floating window layer, for instance) with the results instead of reloading the page?</p>
<p>Well, inspired on <a href="http://weblog.redlinesoftware.com/2008/1/30/willpaginate-and-remote-links">Redline's blog post</a> (which almost worked for the latest version of the will_paginate plugin), I have the solution.</p>
<p>Create a link renderer. I put in under lib/remote_link_renderer.rb so Rails always loads it on startup.</p>
<pre style="font-size: 1.1em; background-color: #dddddd; overflow-x: auto; overflow-y: auto; padding: 0.4em; border: 1px solid #aaaaaa;"><code style="font-size: 1.1em; font-family: Monaco, 'Courier New', monospace; color: #000000;"><span style="font-family: monospace; color: #8b0000;">class</span> <span>RemoteLinkRenderer</span> &lt; <span>WillPaginate</span>:<span style="font-family: monospace; color: #884400;">:LinkRenderer</span>

  <span style="font-family: monospace; color: #8b0000;">def</span> page_link_or_span<span>(</span>page, span_class = <span style="font-family: monospace; color: #00008b;">'current'</span>, text = nil<span>)</span>
    text ||= page<span style="font-family: monospace; color: #006400;">.to_s</span>
    <span style="font-family: monospace; color: #8b0000;">if</span> page and page != current_page
      <span>@template</span><span style="font-family: monospace; color: #006400;">.link_to_remote</span><span>(</span>text, <span>{</span><span style="font-family: monospace; color: #884400;">:url</span> =&gt; url_for<span>(</span>page<span>)</span>, <span style="font-family: monospace; color: #884400;">:method</span> =&gt; <span style="font-family: monospace; color: #884400;">:get</span><span>}</span><span style="font-family: monospace; color: #006400;">.merge</span><span>(</span><span>@remote</span><span>)</span><span>)</span>
    <span style="font-family: monospace; color: #8b0000;">else</span>
      <span>@template</span><span style="font-family: monospace; color: #006400;">.content_tag</span> <span style="font-family: monospace; color: #884400;">:span</span>, text, <span style="font-family: monospace; color: #884400;">:class</span> =&gt; span_class
    <span style="font-family: monospace; color: #8b0000;">end</span>
  <span style="font-family: monospace; color: #8b0000;">end</span>
<span style="font-family: monospace; color: #8b0000;">end</span></code></pre>
<p>On the view, when you are rendering the pager, do it like this:</p>
<pre style="font-size: 1.1em; background-color: #dddddd; overflow-x: auto; overflow-y: auto; padding: 0.4em; border: 1px solid #aaaaaa;"><code style="font-size: 1.1em; font-family: Monaco, 'Courier New', monospace; color: #000000;">&lt;%= will_paginate <span>@collection</span>, <span style="font-family: monospace; color: #884400;">:renderer</span> =&gt; <span style="font-family: monospace; color: #00008b;">'RemoteLinkRenderer'</span> , <span style="font-family: monospace; color: #884400;">:remote</span> =&gt; <span>{</span><span style="font-family: monospace; color: #884400;">:with</span> =&gt; ’value’, <span style="font-family: monospace; color: #884400;">:update</span> =&gt; ‘some_div’<span>}</span> %&gt;</code></pre>
<p>That's it!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.metaduck.com/2010/04/will_paginate-and-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tools for the job</title>
		<link>http://www.metaduck.com/2009/11/tools-for-the-job/</link>
		<comments>http://www.metaduck.com/2009/11/tools-for-the-job/#comments</comments>
		<pubDate>Wed, 04 Nov 2009 15:28:24 +0000</pubDate>
		<dc:creator>Pedro Teixeira</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.metaduck.com/?p=208</guid>
		<description><![CDATA[See the tools / gems / plugins I can't live without.]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-226 alignleft" title="tools" src="http://www.metaduck.com/wp-content/uploads/2009/11/tools.jpeg" alt="tools" width="123" height="123" />Here are some tools / gems / plugins I can't live without:</p>
<h2>IDEs:</h2>
<ul>
<li><a href="http://www.radrails.org/">Aptana Rad Rails</a> - very good at Rails and Ruby. It's based on Eclipse - Java - so it tends to bloat</li>
<li><a href="http://projects.gnome.org/gedit/">gedit</a>- Tiny footprint, simple. Great for web and PHP with the right plugins and conf tweaks</li>
</ul>
<h2>Ruby / Rails plugins:</h2>
<p><span id="more-208"></span></p>
<ul>
<li><a href="http://wiki.github.com/mislav/will_paginate">will_paginate</a> - ActiveRecord pagination made easy</li>
<li><a href="http://github.com/Squeegy/fleximage">fleximage</a> - online image processing Rails plug-in based on rmagick. Very easy to manipulate</li>
<li><a href="http://github.com/whymirror/hpricot">hpricot gem</a> - for parsing HTML and XML. Very resilient to formatting errors. Use it to parse XML feeds with wrong encoding and screen scraping.</li>
<li><a href="http://github.com/binarylogic/authlogic">authlogic</a> - for easy and extensible authentication. With care you can make it easily authenticate with anything.</li>
<li><a href="http://deveiate.org/projects/BlueCloth">BlueCloth</a> gem - for markdown markup</li>
<li><a href="http://rubyeventmachine.com/">eventmachine</a> - scalable asynchronous Ruby servers made easy.</li>
<li><a href="http://wiki.github.com/pgte/styled_objects">styled_objects</a> - simplify stylesheet development and maintenance. By yours truly.</li>
<li><a href="http://github.com/collectiveidea/delayed_job">delayed_job</a> - job queuing for Rails made easy.</li>
<li><a href="http://github.com/cjbottaro/app_config">app_config</a> gem - easy application configuration. Easily differentiate for each environment.</li>
<li><a href="http://wiki.github.com/frabcus/acts_as_xapian">acts_as_xapian</a> - easy ruby and Rails bindings for Xapian - full text search engine. Xapian uses offline index update and does not use a daemon.</li>
<li><a href="http://stonean.com/page/lockdown">lockdown</a> -  authorization system for Rails</li>
<li><a href="http://wiki.github.com/pgte/acts_as_pingable">acts_as_pingable</a> - to expose you Rails stack to external pings. Use it for pingdom.com integration.</li>
<li><a href="http://github.com/giraffesoft/resource_controller">resource_controller</a> - simplifies code for resource controllers (almost no code at all for most cases !)</li>
<li><a href="http://github.com/rubyist/aasm">aasm (acts as state machine)</a> - easily turn your objects into state machines.</li>
</ul>
<h2>Testing</h2>
<ul>
<li><a href="http://cukes.info/">cucumber</a> - BDD at it's best</li>
<li><a href="http://mocha.rubyforge.org/">mocha</a> - intuitive mocking and stubbing</li>
<li><a href="http://rspec.info/">rspec and rspec-rails</a> - Rails testing</li>
<li><a href="http://github.com/thoughtbot/factory_girl">factory_girl</a> - Get rid of fixtures</li>
</ul>
<h2>Database</h2>
<ul>
<li><a href="http://www.mysql.com/">MySQL</a> - I love it, I hate it, I have to live with it...</li>
<li><a href="http://1978th.net/tokyocabinet/">Tokyo Cabinet</a> - fast single table database for key-value store (it already has multiple columns format) with a simple Ruby API. Useful for a lot of things. You can also use <a href="http://1978th.net/tokyotyrant/">Tokyo Tyrant</a> for service.</li>
</ul>
<h2>Deployment</h2>
<ul>
<li><a href="http://www.capify.org">Capistrano</a> - although there are some simpler alternatives around, I simply love Capistrano and use it for almost everything deployment-related.</li>
<li><a href="http://github.com/jamis/capistrano-ext">capistrano-ext</a> - with multistaging deployment, among other goodies.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.metaduck.com/2009/11/tools-for-the-job/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
