The power of GET

28 Sep 2006

Thanks to Per Wigren (aka Tuxie), I got a good pointer to why the ratings at the Rails plugin directory were wrong (everything was a 3): bots.

In my attempt to make the functionality accessible, I provided a fallback to the AJAX ratings. Unfortunately, I chose simple links, aka GETs, as the fallback. Apparently I needed a personal experience with the truism of never letting a GET request make a change to your database.

So, I changed the links to be AJAX only, changed the controller to return 403 unless the request is via XHR, and then recalculated the ratings to exclude all the bot-submitted ones. Now not every plugin is rated a 3, and there are about 20,000 fewer votes in the database. :)



Rails Resource Feeder Fun

27 Sep 2006

I had my first chance to use the new resource feeder yesterday while working on Tesly Jr. (yet to be announced product — contact me to learn more if you’re interested), and I thought I’d write up a quick example of how it’s used. The disclaimer to this post is that the resource feeder plugin is still quite new, and this example could become obsolete at any time.

There’s already a blog post about using this plugin, but I wanted to show something else — an answer to a question I’m sure will pop up again and again in #rubyonrails when people start really using this plugin: how do you customize the contents of the feed with multiple attributes from the model? It’s as simple as passing a proc in to the feeder:

class TestRunsController < ApplicationController
  def feed
    render_atom_feed_for TestRun.find(:all, :include => :test_plans, :order => ‘test_runs.created_at desc’, :limit => 50),
      :item => {
        :title => ‘Test run execution’,
        :description => Proc.new {|r| "Executed test plans: #{r.test_plan_names}

\n\nPass percentage: #{r.percentage.round}%"
}
      }
  end
end


Book update coming soon

25 Sep 2006

I’ve gotten a few emails asking about when the next update to my Rails e-commerce book will be available, so I thought I’d post some information here about that.

My target time frame for the next release is some time in October, probably later rather than sooner. In fact, it may even slip into early November, though I definitely don’t want to go any later than that. The reason for the delay is not related to writing the book, but rather to some of the other projects that have popped up recently.

Well, there is one delay that’s due to the content of the book, and that’s the PayPal information I want to include. In my next update (which may actually be the final update), I want to add more information about shipping, handling addresses, and handling payments. With regards to payments, I intend to write specifically about PayPal, and I’m hoping that I’ll be able to provide better information about integrating Website Payments Pro with Rails. I think the situation is better than it was a few months ago when I first wrote about it, so I need to do some research on that in hopes of providing a better solution.

If you have some suggestions for me on what content you’d like to be added to the book, either as enhancements to topics already covered or entirely new topics, please feel free to contact me directly or leave a response here letting me know what you’d like to see. I’ll do my best to accommodate requests.



Latest Edge Rails: Saving Keystrokes

18 Sep 2006

Here are a couple of changes in the Rails trunk that give me warm fuzzies:

The combination of these two changes will save a fair amount of typing, and that’s definitely a good thing. :)

Now we just need to get the default list of extensions changed in that second patch. I’m thinking .rxml would be a great fit to have no layout by default.