<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" xml:lang="en-US">
  <title>dead dead good - Home</title>
  <id>tag:deaddeadgood.com,2009:mephisto/</id>
  <generator version="0.8.0" uri="http://mephistoblog.com">Mephisto Drax</generator>
  
  <link href="http://deaddeadgood.com/" rel="alternate" type="text/html" />
  <updated>2009-09-28T15:01:09Z</updated>
  <link rel="self" href="http://feeds.feedburner.com/deaddeadgood" type="application/atom+xml" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2009-09-28:72</id>
    <published>2009-09-28T14:58:00Z</published>
    <updated>2009-09-28T15:01:09Z</updated>
    <category term="assets" />
    <category term="css" />
    <category term="nurphy" />
    <category term="rails" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/06-omlQ3HEE/far-future-expires-headers-for-css-images-in-rails" rel="alternate" type="text/html" />
    <title>Far Future Expires Headers for CSS Images in Rails</title>
<content type="html">
            &lt;p&gt;Setting far future expires headers for your static assets noticeably improves the speed at which pages load and is easy to setup in Rails thanks to &lt;a href="http://api.rubyonrails.org/classes/ActionView/Helpers/AssetTagHelper.html"&gt;asset timestamps&lt;/a&gt;. All you need to do is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use &lt;code&gt;image_tag&lt;/code&gt;, &lt;code&gt;stylesheet_link_tag&lt;/code&gt;, &lt;code&gt;javascript_include_tag&lt;/code&gt; and friends in your views.&lt;/li&gt;
&lt;li&gt;Update your web server config to set the correct headers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One problem that's not immediately obvious here is that while your web server is happily adding expires headers to the images you're using in CSS, those requests don't have the timestamp in the query string so the browser will continue to use the cached version after you have updated the file.&lt;/p&gt;

&lt;p&gt;One solution is to instruct the web server to &lt;a href="http://www.dcmanges.com/blog/asset-versioning-in-rails"&gt;only add the expires header to requests that do include the asset timestamp&lt;/a&gt;. While this might be ok if you only have a few images in your CSS, if most of your images are specified this way then you're still not making the most of the browser's cache which was the whole point of the exercise in the first place.&lt;/p&gt;

&lt;p&gt;An alternative solution, and the one we took on &lt;a href="http://nurphy.com"&gt;Nurphy&lt;/a&gt;, is to use ERB templates to generate your stylesheets, and use the Rails' helpers to get asset timestamps in your CSS. It's dead easy, here's how:&lt;/p&gt;

&lt;h3&gt;Create a Stylesheets Controller and a Matching Route&lt;/h3&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;class StylesheetsController &amp;lt; ApplicationController
  caches_page :application, :iphone
end&lt;/code&gt;&lt;/pre&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;map.connect "/stylesheets/:action.css", :controller =&amp;gt; "stylesheets", :format =&amp;gt; "css"&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is just about as simple as you can imagine. We're using page caching to cache the stylesheet to disk, once rendered it will be served like any other static asset.&lt;/p&gt;

&lt;h3&gt;Move Stylesheets to the Views Directory&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;mv public/stylesheets/application.css app/views/stylesheets/application.css.erb
mv public/stylesheets/iphone.css app/views/stylesheets/iphone.css.erb&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Use the image_path Helper&lt;/h3&gt;

&lt;p&gt;Wherever you reference an image in your stylesheet, use the &lt;code&gt;image_path&lt;/code&gt; helper like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;body { background: url(&amp;lt;%= image_path('fade.png') %&amp;gt;); }&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When the template renders this will output something like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;body { background: url(/images/fade.png?1253089219); }&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And that's all there is to it. After each deploy the cached stylesheet will disappear and the next time it's requested it will be regenerated with new timestamps, which in turn will cause the browser to fetch fresh copies of your images.&lt;/p&gt;

&lt;h3&gt;A Note on Asset Hosts&lt;/h3&gt;

&lt;p&gt;We're also using an asset host, for a couple of reasons:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A separate host for static assets can itself improve page load speed.&lt;/li&gt;
&lt;li&gt;We can specify far-future headers on anything served from the asset host, safe in the knowledge that the URL will have been generated using the Rails helpers and will therefore include the timestamp in the query string.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This causes one additional complication with the approach described earlier however. Our asset host doesn't run Rails since it only serves static assets, but the first request for the stylesheet needs to go through Rails so the template can be rendered and written to disk.&lt;/p&gt;

&lt;p&gt;Assuming you're using Capistrano, a simple solution is to add a task that fetches the stylesheets from the Rails host after each deploy. Adding this to &lt;code&gt;deploy.rb&lt;/code&gt; will do the trick:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;task :prime_cache, :roles =&gt; :app do
  run &amp;lt;&amp;lt;-cmd /&gt;&lt;/code&gt;&lt;/pre&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2009/9/28/far-future-expires-headers-for-css-images-in-rails</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2009-05-08:71</id>
    <published>2009-05-08T16:29:00Z</published>
    <updated>2009-05-08T16:30:06Z</updated>
    <category term="ajax" />
    <category term="jquery" />
    <category term="rails" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/7o4oOGptRmE/another-take-on-jquery-rails-and-respond_to" rel="alternate" type="text/html" />
    <title>Another Take on jQuery, Rails and respond_to</title>
<content type="html">
            &lt;p&gt;I been using &lt;a href="http://jquery.com"&gt;jQuery&lt;/a&gt; to do AJAX with Rails a lot recently, and I love it. When I was starting out however, I hit the same problem that seems to trip up everyone: AJAX requests made from jQuery don't trigger &lt;code&gt;format.js&lt;/code&gt; (or &lt;code&gt;wants.js&lt;/code&gt; if you're cool) within the &lt;code&gt;respond_to&lt;/code&gt; block of Rails controller actions.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://ozmm.org/posts/jquery_and_respond_to.html"&gt;The most common solution&lt;/a&gt; I've seen to this problem involves adding a one-liner to your Javascript to instruct jQuery to add a &lt;code&gt;text/javascript&lt;/code&gt; &lt;code&gt;Accept&lt;/code&gt; header to AJAX requests. Which works great in FireFox, but not in Safari.&lt;/p&gt;

&lt;p&gt;The problem seems to be that in Safari, &lt;code&gt;text/javascript&lt;/code&gt; is &lt;em&gt;appended&lt;/em&gt; to the existing &lt;code&gt;Accept&lt;/code&gt; header, so Rails sees something like &lt;code&gt;text/html, */*, text/javascript&lt;/code&gt; which it still interprets as a request for HTML.&lt;/p&gt;

&lt;p&gt;An alternate solution that I've been using is to add the following to &lt;code&gt;environment.rb&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;config.action_controller.use_accept_header = false&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This instructs Rails to use the &lt;code&gt;X-Requested-With&lt;/code&gt; rather than the &lt;code&gt;Accept&lt;/code&gt; header to determine the request format. Since jQuery sets this header in both browsers, Rails controllers will behave as expected. &lt;/p&gt;

&lt;p&gt;One thing to keep in mind is that if your app has an XML or JSON API, you might need to think carefully about whether this is the best way to fix this problem. For a while &lt;a href="http://github.com/rails/rails/commit/2f4aaed7b3feb3be787a316fab3144c06bb21a27"&gt;this became the default in Rails&lt;/a&gt;, although &lt;a href="http://github.com/rails/rails/commit/4ce9931f4f30045b2975328e7d42a02188e35079"&gt;that didn't last very long&lt;/a&gt;.&lt;/p&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2009/5/8/another-take-on-jquery-rails-and-respond_to</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2009-03-07:70</id>
    <published>2009-03-07T17:59:00Z</published>
    <updated>2009-03-16T09:29:28Z</updated>
    <category term="passenger" />
    <category term="rails" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/yJeBQGOXB2Q/installing-passenger-2-1-1-beta" rel="alternate" type="text/html" />
    <title>Installing Passenger 2.1.1 Beta</title>
<content type="html">
            &lt;p&gt;Update: &lt;a href="http://blog.phusion.nl/2009/03/13/phusion-passenger-212-final-released/"&gt;Passenger 2.1.2 (final) has now been released.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The current stable release of &lt;a href="http://rails.lighthouseapp.com/projects/8994/tickets/1957-sessions-break-in-23-with-mongrel"&gt;Passenger (2.0.6) isn't compatible with Rails 2.3 because of recent changes in Rack&lt;/a&gt;. In the app I'm working on, this manifested itself as cookies not been set correctly, making it impossible to log out of the site. The good news is that &lt;a href="http://blog.phusion.nl/2009/03/01/phusion-passenger-211-beta-released-thanks-sponsors/"&gt;the latest beta of Passenger&lt;/a&gt; includes support for Rails 2.3, you can install it (on OS X) as follows:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;curl -O http://phusion-passenger.googlecode.com/files/passenger-2.1.1.gem
sudo gem install passenger-2.1.1
sudo passenger-install-apache2-module&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Follow the on-screen instructions on updating your config, restart Apache and you're done.&lt;/p&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2009/3/7/installing-passenger-2-1-1-beta</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-12-17:55</id>
    <published>2008-12-17T11:42:00Z</published>
    <updated>2009-01-03T10:07:26Z</updated>
    <category term="i18n" />
    <category term="rails" />
    <category term="textmate" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/C6LK_znXJrY/rails-i18n-translation-lookup-in-textmate" rel="alternate" type="text/html" />
    <title>Rails I18n Translation Lookup in TextMate</title>
<content type="html">
            &lt;p&gt;I've been working on internationalizing a Rails app, and along the way I created a simple command to lookup Rails i18n translation keys from within TextMate. You use it like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Highlight a translation key. e.g. &lt;code&gt;'activerecord.errors.messages.inclusion'&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Hit Shift-Command-i.&lt;/li&gt;
&lt;li&gt;The relevant translation is shown on a tool tip, in this case "is not included in the list".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As well as simple keys, the command also works with any additional parameters you'd pass to &lt;code&gt;I18n.t&lt;/code&gt; when using &lt;a href="http://guides.rails.info/i18n.html#_interpolation"&gt;interpolation&lt;/a&gt; or the &lt;a href="http://guides.rails.info/i18n.html#_looking_up_translations"&gt;alternate translation key scoping syntax&lt;/a&gt;. For example highlighting &lt;code&gt;:greater_than, :scope =&gt; [:activerecord, :errors, :messages], :count =&gt; 100&lt;/code&gt; before invoking the command would yield "must be greater than 100" on the tool tip. There's also support for replacing local and instance variables used for interpolation with placeholder strings.&lt;/p&gt;

&lt;p&gt;&lt;del&gt;Since Sven Fuchs has already started an experimental Rails i18n TextMate bundle &lt;a href="http://github.com/phorsfall/rails-i18n/tree/master"&gt;I've forked his rails-i18n repository&lt;/a&gt; and added this to it. Here's how to set it up:&lt;/del&gt;&lt;/p&gt;

&lt;p&gt;The command is included in Sven Fuchs' experimental Rails i18n TextMate bundle, here's how to set it up:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git clone git://github.com/svenfuchs/rails-i18n.git
cp -r rails-i18n/tools/ ~/Library/Application\ Support/TextMate/Bundles/
# You also need the i18n gem
sudo gem install mattetti-i18n --source http://gems.github.com&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The command has the default locale set to &lt;code&gt;:en&lt;/code&gt; and is only loading translations from &lt;code&gt;config/locales/en.yml&lt;/code&gt;. If you need to do something different take a look at the command in TextMate's Bundle Editor and you'll see what you need to change to get things working for you.&lt;/p&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/12/17/rails-i18n-translation-lookup-in-textmate</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-11-17:47</id>
    <published>2008-11-17T12:59:00Z</published>
    <updated>2008-11-17T14:52:46Z</updated>
    <category term="ruby" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/iUalWGN4dJQ/rubys-send-method" rel="alternate" type="text/html" />
    <title>The State of Ruby's send Method</title>
<content type="html">
            &lt;p&gt;Calling a method in Ruby can be thought of as sending a message to an object. This isn't just an abstract concept, it's actually implemented in the language by the &lt;code class="ruby"&gt;send&lt;/code&gt; method.&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;'foo'.length
# =&gt; 3
'foo'.send :length
# =&gt; 3
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is a really important method in Ruby (often used in &lt;a href="http://en.wikipedia.org/wiki/Metaprogramming"&gt;meta-programming&lt;/a&gt;), so important in fact, that just in case you accidentally overwrite &lt;code class="ruby"&gt;send&lt;/code&gt; in your own code, it is aliased as &lt;code class="ruby"&gt;__send__&lt;/code&gt; to make sure it can always be called.&lt;/p&gt;

&lt;p&gt;One aspect of &lt;code class="ruby"&gt;send&lt;/code&gt; that often causes discussion&lt;sup&gt;&lt;a href="#fn1-47"&gt;1&lt;/a&gt;&lt;/sup&gt; is the fact that it allows you to call private methods which would otherwise be inaccessible using the regular method calling syntax, for example:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;class Foo
  private
  def bar
    'baz'
  end
end

foo = Foo.new

foo.bar
# =&gt; NoMethodError: private method `bar' called for #&amp;lt;Foo:0x118fcbc&gt;

foo.send :bar
# =&gt; "baz"
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And for a while, Ruby 1.9 changed the implementation of &lt;code class="ruby"&gt;send&lt;/code&gt; to only allow public methods to be called, introducing a new &lt;code class="ruby"&gt;send!&lt;/code&gt; method&lt;sup&gt;&lt;a href="#fn2-47"&gt;2&lt;/a&gt;&lt;/sup&gt; which continued to allow private methods to be called. However, this has now been removed from Ruby 1.9 in favour of keeping the functionality of &lt;code class="ruby"&gt;send&lt;/code&gt; as is. Instead, a new &lt;code class="ruby"&gt;public_send&lt;/code&gt; method has been introduced which as you might expect will only call public methods.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;There are probably others threads, but &lt;a href="http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/263034"&gt;the send bang method was discussed on the Ruby Talk mailing list&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;For forward compatability with Ruby 1.9 &lt;a href="http://github.com/rails/rails/commit/b01a7c69fc8554c2e696609ea8ab76875d405165"&gt;send was aliased as send! in Rails&lt;/a&gt; as well, although &lt;a href="http://github.com/rails/rails/commit/a1eb4e11c2cccb91483fa15f1a1a0b2ae518d2cf"&gt;this has also since been removed&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/11/17/rubys-send-method</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-10-08:46</id>
    <published>2008-10-08T11:54:00Z</published>
    <updated>2008-10-09T22:03:00Z</updated>
    <category term="rails" />
    <category term="resources" />
    <category term="rspec" />
    <category term="scaffold" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/RC9-UCXWbUU/scaffolding-nested-resources-in-rails" rel="alternate" type="text/html" />
    <title>Scaffolding Nested Resources in Rails</title>
<content type="html">
            &lt;p&gt;Creating &lt;a href="http://adam.blog.heroku.com/past/2007/12/20/nested_resources_in_rails_2/"&gt;nested resources in Rails&lt;/a&gt; can be a little bit tedious, particularly if you're using Rspec and its scaffolding. Updating the controller isn't really a problem, but making the specs pass involves a bit too much busy work. And then there are the views to take care of, and their specs, and don't forget the routing specs while you're at it.&lt;/p&gt;

&lt;p&gt;Now you might suggest that &lt;a href="http://mr.hamptoncatlin.com/"&gt;make_resourceful&lt;/a&gt; and &lt;a href="http://jamesgolick.com/resource_controller/rdoc/index.html"&gt;resource_controller&lt;/a&gt; offer a neat solution to this problem. Well, yes, sometimes. Often though, I find these super controllers tend to be a little too DRY for my tastes, at least on some projects. I'm usually happier starting with some generated code and hacking from there.&lt;/p&gt;

&lt;p&gt;So what I'd really like to be able to do is scaffold out the nested resource and its specs. A quick look around Github turned up &lt;a href="http://github.com/jeremyf/rspec_on_rails_nested_scaffold/tree/master"&gt;rspec_on_rails_nested_scaffold&lt;/a&gt;, a plugin which does just that. It is very nearly perfect for my needs, although &lt;a href="http://github.com/phorsfall/rspec_on_rails_nested_scaffold/tree/master"&gt;I have forked it&lt;/a&gt; and updated the templates used for views and specs with those from the latest versions of Rails and Rspec respectively.&lt;/p&gt;

&lt;p&gt;You can install the plugin like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;script/plugin install git://github.com/phorsfall/rspec_on_rails_nested_scaffold.git&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you already have a &lt;code class="ruby"&gt;Post&lt;/code&gt; resource you can create nested &lt;code class="ruby"&gt;Comments&lt;/code&gt; like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;script/generate rspec_nested_scaffold Comment --owner=Post post_id:integer body:text&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will generate a &lt;code class="ruby"&gt;CommentsController&lt;/code&gt; which includes a &lt;code class="ruby"&gt;before_filter&lt;/code&gt; to load the correct &lt;code class="ruby"&gt;Post&lt;/code&gt; and has Active Record calls scoped accordingly. You also get views which include the correct links and form actions, along with updated controller, view and routing specs. Before you are finished however, there are a few small things you'll need to do by hand:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Update &lt;code&gt;routes.rb&lt;/code&gt;. The generator will add an un-nested &lt;code class="ruby"&gt;map.resources&lt;/code&gt; for our nested resource. In our example, we'd remove this and add the following:
&lt;pre&gt;&lt;code class="ruby"&gt;map.resources :posts, :has_many =&gt; :comments&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;

&lt;li&gt;Create the Active Record associations in your models.
&lt;pre&gt;&lt;code class="ruby"&gt;class Post &amp;lt; ActiveRecord::Base
  has_many :comments
end

class Comments &amp;lt; ActiveRecord::Base
  belongs_to :post
end&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;

&lt;li&gt;If you didn't include a foreign key when you ran the generator, add one to the migration.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;With that done, migrate the database and run the specs which should all pass. You now have an app you can go to work on and hopefully you've saved a bit of time along the way.&lt;/p&gt;

&lt;p&gt;Thanks to &lt;a href="http://github.com/jeremyf"&gt;Jeremy Friesen&lt;/a&gt; for putting the original plugin together.&lt;/p&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/10/8/scaffolding-nested-resources-in-rails</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-08-27:37</id>
    <published>2008-08-27T11:17:00Z</published>
    <updated>2008-09-26T08:25:48Z</updated>
    <category term="activemodel" />
    <category term="activerecord" />
    <category term="activeresource" />
    <category term="callbacks" />
    <category term="rails" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/pNCEX-eK0a0/active-resource-callbacks" rel="alternate" type="text/html" />
    <title>Active Resource Callbacks</title>
<content type="html">
            &lt;p&gt;It looks like &lt;a href="http://github.com/rails/rails/tree/master/activemodel"&gt;work is still on-going&lt;/a&gt; to &lt;a href="http://weblog.techno-weenie.net/2008/1/21/random-rails-tidbits"&gt;extract functionality common to Active Record and Active Resource into a new Active Model library&lt;/a&gt;. Excellent. But I wanted to add a couple of callbacks to Active Resource and I wanted to do it quickly. Thankfully, &lt;a href="http://joshpeek.com/"&gt;someone much smarter than me&lt;/a&gt; has already &lt;a href="http://github.com/rails/rails/commit/aae37bb4f7edd6a1820e420a60560369c6064f33"&gt;extracted callbacks from Active Record&lt;/a&gt;, so getting something working was pretty straight forward.&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;module ActiveResource
  module Callbacks
    CALLBACKS = %w( after_save after_destroy )
    
    def self.included(base)
      [:save, :destroy].each do |method|
        base.send :alias_method_chain, method, :callbacks
      end
      
      base.send :include, ActiveSupport::Callbacks
      base.define_callbacks *CALLBACKS
    end
    
    def save_with_callbacks
      returning save_without_callbacks do
        run_callbacks(:after_save) unless new?
      end
    end
    
    def destroy_with_callbacks
      returning destroy_without_callbacks do
        run_callbacks(:after_destroy)
      end
    end
  end
end

ActiveResource::Base.send :include, ActiveResource::Callbacks&lt;/code&gt;&lt;/pre&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/8/27/active-resource-callbacks</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-08-18:33</id>
    <published>2008-08-18T21:33:00Z</published>
    <updated>2008-08-18T21:34:45Z</updated>
    <category term="arduino" />
    <category term="barcamp" />
    <category term="ruby" />
    <category term="shoes" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/hS-Vp-8NLGs/shoes-and-arduino-etch-a-sketch" rel="alternate" type="text/html" />
    <title>Shoes and Arduino Etch a Sketch</title>
<content type="html">
            &lt;p&gt;Here's a short video of me struggling to demo &lt;a href="http://deaddeadgood.com/assets/2008/8/18/etch_a_sketch.tar.gz"&gt;an Etch a Sketch app&lt;/a&gt; which formed part of a presentation I gave at &lt;a href="http://barcampleeds.com/"&gt;BarCamp Leeds&lt;/a&gt; as part of &lt;a href="http://www.simonwheatley.co.uk/2008/08/13/barcamp-leeds-my-last-project/"&gt;Simon Wheatley's 'My Last Project' session&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&amp;lt;object height="350" width="425"&gt;
&amp;lt;param&gt;&amp;lt;/param&gt;
&amp;lt;embed src="http://www.youtube.com/v/017loHbDUCE" height="350" width="425"&gt;
&amp;lt;/embed&gt;
&amp;lt;/object&gt;&lt;/p&gt;

&lt;p&gt;The code is a bit rough in places but might be of interest if like me you're getting started with either &lt;a href="http://arduino.cc/"&gt;Arduino&lt;/a&gt; or &lt;a href="http://shoooes.net/"&gt;Shoes&lt;/a&gt; development.&lt;/p&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/8/18/shoes-and-arduino-etch-a-sketch</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-08-03:31</id>
    <published>2008-08-03T10:17:00Z</published>
    <updated>2008-08-03T10:17:58Z</updated>
    <category term="activeresource" />
    <category term="gem" />
    <category term="pagination" />
    <category term="rails" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/4RWmBv-Zh9w/resourceful_pagination" rel="alternate" type="text/html" />
    <title>resourceful_pagination</title>
<content type="html">
            &lt;p&gt;I've been doing quite a bit of work recently on an Active Resource project and needed to add pagination to one of our resources. I had a quick look around to see what other people were doing, and while it looks like &lt;a href="http://github.com/mislav/will_paginate/tree/agnostic/"&gt;work is underway to add support for Active Resource&lt;/a&gt; (and ORMs other than Active Record) to &lt;a href="http://github.com/mislav/will_paginate/"&gt;will_paginate&lt;/a&gt; I don't think it's quite ready just yet. So while we wait, may I present &lt;a href="http://github.com/phorsfall/resourceful_pagination/"&gt;resourceful_pagination&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you want to dive straight in, take a look at the &lt;a href="http://github.com/phorsfall/resourceful_pagination/tree/master/README.txt"&gt;readme&lt;/a&gt; then install the gem with:&lt;p&gt;

&lt;pre&gt;&lt;code&gt;sudo gem install phorsfall-resourceful_pagination --source http://gems.github.com&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With the gem installed you get a shiny new &lt;code&gt;ActiveResource::Base#paginate&lt;/code&gt; method. Use it like this:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;MyResource.paginate(:page =&gt; params[:page])&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This returns a &lt;code&gt;WillPaginate::Collection&lt;/code&gt; which you can use with will_paginate's view helpers as usual.&lt;/p&gt;

&lt;p&gt;Easy, right?, Well, sort of. The gem makes a few assumptions about your Active Resource class and your RESTful resource. If you want to use this you'll probably need to make a few changes. First you need to add two class methods to your Active Resources.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A &lt;code&gt;count&lt;/code&gt; method which returns the total number of items. This could call a custom count action on the app server.&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;per_page&lt;/code&gt; method indicating how many records you require per page.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Something like this would do the trick:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;class MyResource &amp;lt; ActiveResource::Base
  @@per_page = 10
  cattr_reader :per_page

  def self.count
    get(:count)['count']
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You also need the &lt;code&gt;index&lt;/code&gt; action of the controller on the app server to handle the &lt;code&gt;:starting_at&lt;/code&gt; and &lt;code&gt;:per_page&lt;/code&gt; parameters. These map to &lt;code&gt;:offset&lt;/code&gt; and &lt;code&gt;:limit&lt;/code&gt; in SQL and can be passed straight through to Active Record.&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;MyResourcesController &amp;lt; ApplicationController
  def index
    MyResource.find :all, :limit =&gt; params[:per_page], :offset =&gt; params[:starting_at]
    # Render XML etc.
  end

  def count
    count = MyResource.count
    render :xml =&gt; { :count =&gt; count }
  end
end&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And that's about it. There's a little bit more to do if you have a nested resource, but there's a bit more on that in the readme.&lt;/p&gt;

&lt;p&gt;Enjoy.&lt;/p&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/8/3/resourceful_pagination</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-06-29:29</id>
    <published>2008-06-29T18:50:00Z</published>
    <updated>2008-06-29T18:51:53Z</updated>
    <category term="rails" />
    <category term="rspec" />
    <category term="ruby" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/QS9UENeEOn0/an-include_any-matcher-for-rspec" rel="alternate" type="text/html" />
    <title>An include_any Matcher for RSpec</title>
<content type="html">
            &lt;p&gt;Writing custom &lt;a href="http://rspec.rubyforge.org/rdoc/classes/Spec/Matchers.html"&gt;RSpec expectation matchers&lt;/a&gt; is a great way to enhance the readability of your specifications. As an example, here's a simple matcher to check whether a collection contains any of the given items. An example will make things clearer:&lt;/p&gt;

&lt;pre&gt;
&lt;code class="ruby"&gt;# Passing example
odds  = [1,3,5,7,9]
evens = [2,4,6,8]
odds.should_not include_any(*evens)&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;One thing to note is that &lt;code&gt;include_any&lt;/code&gt; expects multiple arguments rather than a collection, hence the splat. Here's the code:&lt;/p&gt;

&lt;pre&gt;
&lt;code class="ruby"&gt;module Spec
  module Matchers
    def include_any(*args)
      IncludeAny.new(*args)
    end
  
    class IncludeAny
      def initialize(*args)
        @args = args
      end
    
      def matches?(target)
        @target = target
        @target.include_any?(*@args)
      end
    
      def failure_message
        "expected #{@target.inspect} to include one or more elements from #{@args.inspect}"
      end
    
      def negative_failure_message
        "expected #{@target.inspect} not to include any elements from #{@args.inspect}"
      end
    end
  end
end&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;This is about as trivial as a custom matcher gets. All of the work is done by the &lt;code&gt;include_any?&lt;/code&gt; method, which doesn't actually exist as part of the &lt;a href="http://www.ruby-doc.org/core/"&gt;core Ruby API&lt;/a&gt;. In fact it's a simple extension to &lt;code&gt;Enumerable&lt;/code&gt; that I think I originally borrowed from &lt;a href="http://merbivore.com/"&gt;Merb&lt;/a&gt;. Put the following in &lt;code&gt;config/initializers/core_extensions.rb&lt;/code&gt; or similar to use it in a &lt;a href="http://www.rubyonrails.org/"&gt;Rails&lt;/a&gt; app.&lt;/p&gt;

&lt;pre&gt;
&lt;code class="ruby"&gt;module Enumerable
  def include_any?(*args)
    args.any? { |arg| self.include?(arg) }
  end
end&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;Which custom matchers are you using?&lt;/p&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/6/29/an-include_any-matcher-for-rspec</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-06-25:28</id>
    <published>2008-06-25T23:19:00Z</published>
    <updated>2008-06-25T23:22:28Z</updated>
    <category term="activerecord" />
    <category term="rails" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/lhxsd1UKZPY/how-to-bypass-attr_accessible-and-attr_protected-in-rails" rel="alternate" type="text/html" />
    <title>How to Bypass attr_accessible and attr_protected in Rails</title>
<content type="html">
            &lt;p&gt;Mass assignment in Rails is super handy and saves heaps of code, especially in your controllers. As everyone knows however, &lt;a href="http://railscasts.com/episodes/26"&gt;hackers love mass assignment&lt;/a&gt; so you really need to use &lt;code&gt;attr_accessible&lt;/code&gt; or &lt;code&gt;attr_protected&lt;/code&gt; to protect your models.&lt;/p&gt;

&lt;p&gt;But what happens if you want to mass assign model attributes which are otherwise protected? It would be simple enough to create your own method to do this, but if you take a look at &lt;a href="http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001374"&gt;the source&lt;/a&gt; you'll see that Rails already has it covered. Here's the method signature for &lt;code&gt;ActiveRecord::Base#attributes=&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;def attributes=(new_attributes, guard_protected_attributes = true)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;That optional second parameter lets you bypass &lt;code&gt;attr_accessible&lt;/code&gt; and &lt;code&gt;attr_protected&lt;/code&gt; exactly as we'd like. But how do we call this? Well, you use &lt;code&gt;send&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;@model.send :attributes=, attributes, false&lt;/code&gt;&lt;/pre&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/6/25/how-to-bypass-attr_accessible-and-attr_protected-in-rails</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-04-20:15</id>
    <published>2008-04-20T21:42:00Z</published>
    <updated>2008-04-20T21:48:34Z</updated>
    <category term="rails" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/-HspbGNxZwc/contributing-to-rails" rel="alternate" type="text/html" />
    <title>Contributing to Rails</title>
<content type="html">
            &lt;p&gt;Encouraged by &lt;a href="http://deaddeadgood.com/2008/4/13/conditional-page-caching-in-rails#comments"&gt;a couple of kind comments&lt;/a&gt; &lt;a href="http://rails.lighthouseapp.com/projects/8994/tickets/25-allow-if-option-for-caches_page"&gt;I submitted a patch&lt;/a&gt; for the change I wrote about in my &lt;a href="http://deaddeadgood.com/2008/4/13/conditional-page-caching-in-rails"&gt;previous post&lt;/a&gt;, and &lt;a href="http://github.com/rails/rails/commit/14a40804a29a57ad05ca6bffbe1e5334089593a9"&gt;as of yesterday&lt;/a&gt; you can now do something like this in edge Rails.&lt;/p&gt;

&lt;pre&gt;
&lt;code class="ruby"&gt;caches_page :index, :if =&gt; Proc.new { |c| !c.request.format.json? }&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;I'd not used &lt;a href="http://lighthouseapp.com/"&gt;Lighthouse&lt;/a&gt; before and I'm still getting my head around everything &lt;a href="http://git.or.cz/"&gt;Git&lt;/a&gt;. If you're in a similar position, you might find these links useful too:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.tpope.net/rails-git-best-practices"&gt;Best Practices for Contributing to Rails with Git&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.thechrisoshow.com/2008/4/13/five-rails-tips/"&gt;Five tips for contributing to Rails&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://rails.lighthouseapp.com/projects/8994/ticket-guidelines"&gt;Ticket Guidelines&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/4/20/contributing-to-rails</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-04-13:7</id>
    <published>2008-04-13T19:16:00Z</published>
    <updated>2008-04-20T21:59:22Z</updated>
    <category term="caching" />
    <category term="rails" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/68rMRFNlb0c/conditional-page-caching-in-rails" rel="alternate" type="text/html" />
    <title>Conditional Page Caching in Rails</title>
<content type="html">
            &lt;p class="update"&gt;Update 20/04/2008: &lt;a href="http://deaddeadgood.com/2008/4/20/contributing-to-rails"&gt;I submitted a patch and this is now in edge Rails&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I &lt;a href="http://deaddeadgood.com/2008/3/27/really-simple-blog-badges-in-rails-2-0"&gt;created the JSON feed for my deadtre.es blog badge&lt;/a&gt;, one thing I didn't take care of was caching. As the contents of the feed will always be the same for a given URL no matter which user makes the request, it's a prime candidate for page caching. All I need to do is add &lt;code&gt;caches_page :index&lt;/code&gt; to my controller, and Rails takes care of caching the index action for me. However, there's a problem here as the HTML format index action will also be cached, and unlike the JSON feed this does vary based on the logged on user (if you're looking at your own bookmarks you get edit and delete links for example) and so it isn't as suitable for page caching. What I'd really like to do here is to specify a condition that will be evaluated before the page is cached, much as the &lt;a href="http://www.noobkit.com/show/ruby/rails/rails-edge/actionpack-edge/actioncontroller/sessionmanagement/classmethods/session.html"&gt;session &lt;/a&gt; method does.&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;caches_page :index, :if =&gt; Proc.new { |c| c.request.format.json? }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Unfortunately, a quick look at &lt;a href="http://www.noobkit.com/show/ruby/rails/rails-edge/actionpack-edge/actioncontroller/caching/pages/classmethods/caches_page.html"&gt;the docs for caches_page&lt;/a&gt; tells me that it doesn't support this. But looking at the source code I can see that &lt;code&gt;caches_page&lt;/code&gt; is really just a nice shortcut for setting up an &lt;code&gt;after_filter&lt;/code&gt; to perform the caching. So, instead of calling &lt;code&gt;caches_page&lt;/code&gt; I could do this directly myself, and check the format of the page requested so that only the JSON feed is cached:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;after_filter(:only =&gt; :index) { |c| c.cache_page if c.request.format.json? }&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now, although this works, it doesn't check that caching is enable (as &lt;code&gt;caches_page&lt;/code&gt; does) and it's also not that pretty. Instead, I decided to override &lt;code&gt;caches_page&lt;/code&gt; by dropping the following in my ApplicationController.&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;def self.caches_page(*actions)
  return unless perform_caching
  options = actions.extract_options!
  after_filter(:only =&gt; actions) { |c| c.cache_page if options[:if].nil? or options[:if].call(c) }
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is pretty similar to the original &lt;code&gt;caches_page&lt;/code&gt; except that it evaluates any &lt;code&gt;:if&lt;/code&gt; proc passed in before caching the page. Now, I can now call &lt;code&gt;caches_page&lt;/code&gt; with the syntax I originally wanted:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;caches_page :index, :if =&gt; Proc.new { |c| c.request.format.json? }&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Job done.&lt;/p&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/4/13/conditional-page-caching-in-rails</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-04-02:4</id>
    <published>2008-04-02T21:12:00Z</published>
    <updated>2008-04-02T21:14:01Z</updated>
    <category term="git" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/6pCGoogHe4U/building-git-on-ubuntu-6-06" rel="alternate" type="text/html" />
    <title>Building Git on Ubuntu 6.06</title>
<content type="html">
            &lt;p&gt;I'm spending some time updating my Rails projects to use &lt;a href="http://www.capify.org/"&gt;Capistrano 2&lt;/a&gt; and &lt;a href="http://git.or.cz/"&gt;Git&lt;/a&gt;. Here are the steps I took to build &lt;a href="http://git.or.cz/"&gt;Git&lt;/a&gt; on my Ubuntu 6.06 slice.&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
sudo apt-get install curl libcurl3-gnutls-dev libexpat1-dev
wget http://kernel.org/pub/software/scm/git/git-1.5.4.5.tar.gz
tar xvf git-1.5.4.5.tar.gz
cd git-1.5.4.5.tar.gz
NO_TCLTK=yes make prefix=/usr/local all
NO_TCLTK=yes sudo make prefix=/usr/local install
&lt;/code&gt;
&lt;/pre&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/4/2/building-git-on-ubuntu-6-06</feedburner:origLink></entry>
  <entry xml:base="http://deaddeadgood.com/">
    <author>
      <name>paul</name>
    </author>
    <id>tag:deaddeadgood.com,2008-03-27:3</id>
    <published>2008-03-27T20:34:00Z</published>
    <updated>2009-06-25T11:09:47Z</updated>
    <category term="json" />
    <category term="rails" />
    <link href="http://feedproxy.google.com/~r/deaddeadgood/~3/gcJy4xJJdto/really-simple-blog-badges-in-rails-2-0" rel="alternate" type="text/html" />
    <title>Really Simple Blog Badges in Rails 2.0</title>
<content type="html">
            &lt;p&gt;When I wanted a quick (&lt;a href="http://ajaxian.com/archives/is-easy-implementation-the-same-as-good-code"&gt;and arguably dirty&lt;/a&gt;) way to show my current reading list from deadtre.es on this blog, I figured that it was time to play with &lt;a href="http://blog.codefront.net/2007/10/10/new-on-edge-rails-json-serialization-of-activerecord-objects-reaches-maturity/"&gt;the JSON support which was baked in Rails 2.0&lt;/a&gt;. Wanting to keep things super simple, all I wanted to do was:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;Create a simple JSON feed I can include via a &lt;code&gt;&amp;lt;script&gt;&lt;/code&gt; tag. (I'll write a simple Javascript callback which will insert my reading list into each page. If I decide to make this easier for users I'll put together the usual configuration page where people can play with the look and feel of their badge and get some code to copy and paste.)&lt;/li&gt;
&lt;li&gt;Keep things RESTful. Each user already has a URL for their bookmarks so I really wanted to avoid to avoid creating new controllers or actions.&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Cutting to the chase, this pretty much turns out to be a one-liner in Rails. Here's an example:&lt;/p&gt;

&lt;pre&gt;&lt;code class="ruby"&gt;
class BookmarksController &amp;lt; ApplicationController
  session :off, :only =&gt; :index, :if =&gt; Proc.new { |request| request.format.json? }
  
  def index
    # fetch bookmarks ...
    respond_to do |format|
      format.json do     
        excluded_book_attrs = [:aws_domain, :id, :created_at, :updated_at]        
        excluded_bookmark_attrs = [:book_id, :id, :updated_at, :user_id]
        render :json =&gt; @bookmarks.to_json(:except =&gt; excluded_bookmark_attrs, :include =&gt; { :book =&gt; { :except =&gt; excluded_book_attrs }}), :callback =&gt; 'show_deadtrees_books'
      end
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;It doesn't get much simpler than that! There are a couple of things worth pointing out:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;code&gt;render :json&lt;/code&gt; takes care of setting the content type to application/json in the reponse header. Additionally, it wraps the JSON in a call to the method specified by the &lt;code&gt;:callback&lt;/code&gt; option. (I should allow users to override this via the querystring to avoid name conflicts in their Javascript or to remove the callback altogether to support use outside of a &lt;code&gt;&amp;lt;script&gt;&lt;/code&gt; tag.)&lt;/li&gt;

&lt;li&gt;You can include Active Record associations when calling &lt;code&gt;to_json&lt;/code&gt; using &lt;code&gt;:include&lt;/code&gt;&lt;/li&gt;

&lt;li&gt;You can also control which attributes are serialized (including those on associations) using the &lt;code&gt;:only&lt;/code&gt; and &lt;code&gt;:except&lt;/code&gt; options.&lt;/li&gt;

&lt;li&gt;I've disabled sessions for JSON requests to the index action since they're not required and carry a reasonable overhead.&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;With that in place, all you need to do is implement your Javascript callback (&lt;a href="/javascripts/custom.js"&gt;borrow mine&lt;/a&gt; if you like) and your blog badge is done!&lt;/p&gt;
          </content>  <feedburner:origLink>http://deaddeadgood.com/2008/3/27/really-simple-blog-badges-in-rails-2-0</feedburner:origLink></entry>
</feed>
