<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Holland On Rails Weblog Feed</title>
    <link>http://www.hollandonrails.nl</link>
    <description>Weblog over Ruby On Rails in den Nederlandsche taal</description>
    <item>
      <title>JSONP</title>
      <description>&lt;p&gt;Unfortunately, by default there is no &lt;del&gt;&lt;span class="caps"&gt;JSONP&lt;/span&gt; mime type defined in Rails&lt;/del&gt;&lt;em&gt;usage of the &lt;span class="caps"&gt;JSONP&lt;/span&gt; mime type defined in the documentation of Rails&lt;/em&gt;. So you&amp;rsquo;re left a bit in the void on that part. &lt;del&gt;I thought Rails was a one stop solution.&lt;/del&gt;&#8230;&lt;/p&gt;
&lt;p&gt;Luckily, the solution is easy:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;
class ApplicationController &amp;amp;lt; ActionController::Base
  protected
  def render_json(json, options={})
    callback, variable = params[:callback], params[:variable]
    response = if callback &amp;amp;amp;&amp;amp;amp; variable
                   "var #{variable} = #{json};\n#{callback}(#{variable});"
                 elsif variable
                   "var #{variable} = #{json};"
                 elsif callback
                   "#{callback}(#{json});"
                 else
                   json
                 end
               end
    render({:content_t ype =&amp;amp;gt; :js, :text =&amp;amp;gt; response}.merge(options))
  end
end
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And you&amp;rsquo;re able to render your jsonp replies by calling:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;
format.js {&lt;/p&gt;
&lt;ol&gt;
	&lt;li&gt;do your thang &lt;br /&gt;
    render_json result.to_json&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;del&gt;Still, it&amp;rsquo;s a shame you have to hack this in yourself.&lt;del&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;As Jan de Poorter rightfully noted: The functionality is available; just poorly documented. My lesson here is to check the Rails source more often.&lt;/em&gt;&lt;/p&gt;</description>
      <author>jeroenbulters@gmail.com (Jeroen Bulters)</author>
      <category>hor</category>
      <pubDate>Wed, 12 Oct 2011 12:21:35 +0200</pubDate>
      <link>http://hollandonrails.nl/articles/549-JSONP</link>
      <guid>http://hollandonrails.nl/articles/549-JSONP</guid>
    </item>
    <item>
      <title>Easy Authentication with OmniAuth</title>
      <description>&lt;p&gt;If you ever want to implement OAuth or OpenID to authenticate and connect users with different accounts, you should check out the OmniAuth gem! This piece of Rack middleware takes care of all the difficult stuff like having to implement and understand all the different API&amp;#8217;s. It makes it very easy and clean to implement authentication with (for example) Twitter, OpenID and Facebook.&lt;/p&gt;
&lt;p&gt;There are two excellent railscasts available on how to implement the oauth gem:&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://railscasts.com/episodes/235-omniauth-part-1"&gt;http://railscasts.com/episodes/235-omniauth-part-1&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href="http://railscasts.com/episodes/236-omniauth-part-2"&gt;http://railscasts.com/episodes/236-omniauth-part-2&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;More information about this gem can be found at the &lt;a href="https://github.com/intridea/omniauth"&gt;GitHub Page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Tip: If you need nice twitter and facebook buttons on your authentication page, you can find them &lt;a href="https://github.com/intridea/authbuttons"&gt;here&lt;/a&gt;&lt;/p&gt;</description>
      <author>chiel@chielwester.nl (Chiel Wester)</author>
      <category>hor</category>
      <pubDate>Mon, 08 Nov 2010 09:32:50 +0100</pubDate>
      <link>http://hollandonrails.nl/articles/547-Easy-Authentication-with-OmniAuth</link>
      <guid>http://hollandonrails.nl/articles/547-Easy-Authentication-with-OmniAuth</guid>
    </item>
    <item>
      <title>RubyGems</title>
      <description>&lt;p&gt;Nick Quaranto recently wrote a great &lt;a href="http://rubylearning.com/blog/2010/10/06/gem-sawyer-modern-day-ruby-warrior/"&gt;blog&lt;/a&gt; post about RubyGems, and creating gems.&lt;/p&gt;
&lt;p&gt;It&amp;#8217;s especially helpful for people new to ruby and rubygems, or people who want to create their own gem.&lt;/p&gt;</description>
      <author>daniel.willemse@holder.nl (Daniel Willemse)</author>
      <category>hor</category>
      <pubDate>Sun, 10 Oct 2010 20:34:16 +0200</pubDate>
      <link>http://hollandonrails.nl/articles/546-RubyGems</link>
      <guid>http://hollandonrails.nl/articles/546-RubyGems</guid>
    </item>
    <item>
      <title>ControlTower</title>
      <description>&lt;p&gt;Although this blog is called HollandOn&lt;b&gt;Rails&lt;/b&gt;, and this post is about something that currently does not work with Rails I thought it would still be interesting, mainly because &amp;#8211; possibly in the future &amp;#8211; Rails might be supported.&lt;/p&gt;
&lt;p&gt;Yesterday, &lt;a href="http://www.macruby.org/blog/2010/09/20/announcing-control-tower.html" alt="MacRuby releases ControlTower 1.0"&gt;MacRuby released ControlTower 1.0&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;ControlTower is a &amp;#8216;simple&amp;#8217; web/application server built entirely on MacRuby and thus playing extremely nice with your Mac (sorry non-Macheads). It is built to run all Rack applications which are &amp;#8216;supported by&amp;#8217; MacRuby; which means Rails is out of the picture for the moment.&lt;/p&gt;
&lt;p&gt;What does a MacRuby webserver mean? Well, basically, you can compare ControlTower with a MacOS X version of Unicorn; but instead of using native Un*x calls (i.e. forks and selects), it uses Apple&amp;#8217;s GrandCentralDispatch (&lt;span class="caps"&gt;GVD&lt;/span&gt;) as a socketmanager. By default you will not notice any difference with &amp;#8211; say &amp;#8211; Thin; as &lt;span class="caps"&gt;GCD&lt;/span&gt; uses a serial connection queue by default. But if you mac allows it, and of course you configure it correctly, it will allow you 75 concurrent incoming requests on a 8-core Mac Pro.&lt;/p&gt;
&lt;p&gt;Scalability out of the box.&lt;/p&gt;</description>
      <author>jeroenbulters@gmail.com (Jeroen Bulters)</author>
      <category>hor</category>
      <pubDate>Tue, 21 Sep 2010 08:27:54 +0200</pubDate>
      <link>http://hollandonrails.nl/articles/545-ControlTower</link>
      <guid>http://hollandonrails.nl/articles/545-ControlTower</guid>
    </item>
    <item>
      <title>Charts</title>
      <description>&lt;p&gt;If you want to have some charts in your application there are numerous ways to achieve this.&lt;/p&gt;
&lt;p&gt;In the following &lt;a href="http://railscasts.com/episodes/223-charts"&gt;railscast&lt;/a&gt; (june 19th)&lt;/p&gt;
&lt;p&gt;Ryan Bates shows you a couple of these ways and goes indepth on a js library called &lt;a href="http://www.highcharts.com/"&gt;Highcharts&lt;/a&gt;. This library is 100% js so no extra dependencies are needed, and the api is pretty straightforward aswell.&lt;/p&gt;
&lt;p&gt;I found the examples pretty easy to follow and i&amp;#8217;ll definitely be using them the next time i need a chart.&lt;/p&gt;</description>
      <author>daniel.willemse@holder.nl (Daniel Willemse)</author>
      <category>hor</category>
      <pubDate>Mon, 13 Sep 2010 08:01:17 +0200</pubDate>
      <link>http://hollandonrails.nl/articles/544-Charts</link>
      <guid>http://hollandonrails.nl/articles/544-Charts</guid>
    </item>
    <item>
      <title>Quicktip: hashes in find conditions</title>
      <description>&lt;p&gt;Have you ever made a find condition with a lot of questionmarks in it where you wanted the same input for those questionmarks?&lt;/p&gt;
&lt;p&gt;Like this:&lt;br /&gt;
&lt;code&gt;
named_scope :search, lambda {|x| {
  :conditions =&amp;gt; ["title like ? or lead like ? or content like ?", x, x, x]
}}
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;You can actually use hashes in stead of questionmarks. So the above code could be refactored into this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;
named_scope :search, lambda {|x| {
  :conditions =&amp;gt; ["title like :search or lead like :search or content like :search", { :search =&amp;gt; x}]
}}
&lt;/code&gt;&lt;/p&gt;</description>
      <author>roy.van.der.meij@holder.nl (Roy van der Meij)</author>
      <category>hor</category>
      <pubDate>Thu, 09 Sep 2010 13:26:43 +0200</pubDate>
      <link>http://hollandonrails.nl/articles/543-Quicktip-hashes-in-find-conditions</link>
      <guid>http://hollandonrails.nl/articles/543-Quicktip-hashes-in-find-conditions</guid>
    </item>
    <item>
      <title>Quicktip: localghost</title>
      <description>&lt;p&gt;I just wanted to share a quick tip I just found on the interwebz.&lt;/p&gt;
&lt;p&gt;I happen to add hostnames to /etc/hosts regulary in order to have different hostnames for all apps I am working on. With localghost you can easily add, remove, enable and disable hostnames pointing to localhost with just a few mouse clicks.&lt;/p&gt;
&lt;p&gt;For people who are not using passenger and the prefpane for development this might be very handy.&lt;/p&gt;
&lt;p&gt;Website: http://scotchi.net/localghost/&lt;br /&gt;
Github: http://github.com/scotchi/Localghost&lt;/p&gt;</description>
      <author>wijnand@nedbsd.eu (Wijnand Wiersma)</author>
      <category>hor</category>
      <pubDate>Tue, 07 Sep 2010 20:09:10 +0200</pubDate>
      <link>http://hollandonrails.nl/articles/542-Quicktip-localghost</link>
      <guid>http://hollandonrails.nl/articles/542-Quicktip-localghost</guid>
    </item>
    <item>
      <title>to_s FTDRY</title>
      <description>&lt;p&gt;Here is just a quick tip: define more to_s methods on your models to &lt;span class="caps"&gt;DRY&lt;/span&gt; up you views. It&amp;#8217;s a very Ruby thing to do and if you keep this method fairly on top of your classes it won&amp;#8217;t be very confusing for other developers.&lt;/p&gt;
&lt;p&gt;For one project I have 3 models: include, exclude and split. When I want to display them I only want to show the only defined property they have: path&lt;/p&gt;
&lt;p&gt;I display them regularly in views and it gets used in background processes where it is concatenated into a bigger string.&lt;/p&gt;
&lt;p&gt;So instead of writing include.path everytime I went for this approach:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;
def to_s
  path
end
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;From now on I can do something like this in my views:&lt;br /&gt;
&lt;code&gt;
&amp;lt;li&amp;gt;&amp;lt;%= include %&amp;gt;&amp;lt;/li&amp;gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;And where it gets concatenated:&lt;br /&gt;
&lt;code&gt;
"#{first_include} something here #{second_include}"
&lt;/code&gt;&lt;/p&gt;
or a array gets joined:
&lt;p&gt;&lt;code&gt;
includes.join(" ")
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Another nice example might be a person class where you display the persons name regularly in views. If you keep the parts of the name in multiple properties you are getting a bigger win:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;
def name
  [first_name, last_name_prefix, last_name].reject{|x|x.blank?}.join ' '
 end
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;So if you display an object as a string a lot defining a to_s method and just put in your plain object in your view will certainly a nice way to get more &lt;span class="caps"&gt;DRY&lt;/span&gt;.&lt;/p&gt;</description>
      <author>wijnand@nedbsd.eu (Wijnand Wiersma)</author>
      <category>hor</category>
      <pubDate>Thu, 02 Sep 2010 22:22:24 +0200</pubDate>
      <link>http://hollandonrails.nl/articles/541-to-s-FTDRY</link>
      <guid>http://hollandonrails.nl/articles/541-to-s-FTDRY</guid>
    </item>
    <item>
      <title>It's Rails 3 time!</title>
      <description>&lt;p&gt;After years of development by the Rails Community the &lt;a href="http://weblog.rubyonrails.org/2010/8/29/rails-3-0-it-s-done"&gt;3rd version of Rails is finally ready&lt;/a&gt;! The number of new features and improvements is enormous!&lt;/p&gt;
&lt;p&gt;Are you ready to upgrade your application to this new version of Rails? Just use the &lt;a href="http://www.railsupgradehandbook.com/"&gt;Rails 3 upgrade handbook&lt;/a&gt;&lt;/p&gt;</description>
      <author>chiel@chielwester.nl (Chiel Wester)</author>
      <category>hor</category>
      <pubDate>Mon, 30 Aug 2010 11:29:09 +0200</pubDate>
      <link>http://hollandonrails.nl/articles/540-It-s-Rails-3-time-</link>
      <guid>http://hollandonrails.nl/articles/540-It-s-Rails-3-time-</guid>
    </item>
    <item>
      <title>Rails 3.0: Release candidate 2</title>
      <description>&lt;p&gt;&lt;a href="http://weblog.rubyonrails.org/2010/8/24/rails-3-0-release-candidate-2"&gt;According to &lt;span class="caps"&gt;DHH&lt;/span&gt;&lt;/a&gt; the release candidate process is progressing as planned. This second candidate has very few changes over the first, which means that unless any blockers are discovered with this release, we&#8217;re targeting the final release of Rails 3.0 for this week(!!!).&lt;/p&gt;</description>
      <author>stephan.kaag@holder.nl (Stephan Kaag)</author>
      <category>hor</category>
      <pubDate>Fri, 27 Aug 2010 15:55:02 +0200</pubDate>
      <link>http://hollandonrails.nl/articles/539-Rails-3-0-Release-candidate-2</link>
      <guid>http://hollandonrails.nl/articles/539-Rails-3-0-Release-candidate-2</guid>
    </item>
  </channel>
</rss>
