Blog
Saturday 20 September 2008
Sorted Homepage With Ruby on Rails
Ruby on Rails Homepage Sorting I have a magazine site with a typical homepage that features the latest items in each category. Something that has been subtly gnawing at my sanity for a long time is that items were showing up in the order I placed them in my view, not based on creation date. So if there were a whole bunch of news songs, for example, you’d never know it because they were always at the bottom of the page, and if the films hadn’t been updated in... More
Monday 18 August 2008
Rails Image Uploads Model
I have a magazine site with a fair number of models containing uploaded image columns. I started with a chunk of code in each model to handle the image save eg @album.save_image(@image). It was working fine but it didn’t feel right, since each model contained the exact same code for handling the save, it seemed to go completely in the face of all the noble, DRY Rails way. It occurred to me that the thing to do was refactor to a generic ImageSave model that could be called by any ... More
Sunday 10 August 2008
Optimizing Ruby on Rails Database Query Performance
One important step in optimizing Rails performance is at the query level. This can be done in a number of steps. 1. Database Gluttony: No optimization While you’re learning Rails or first developing an application it’s very convenient to set up your controller to find @albums this way: @albums = Album.find(:all, :limit => 20) With this basic fi... More
Sunday 13 July 2008
LastFM API Plugin For Rails
I created my first Rails plugin recently... It provides some easy ways to interact with the LastFM API. There are generic methods for unauthorized RESTful GET queries, authorized RESTful GET queries, and RESTful POST query, as well as helper methods for generating a redirect path if a session has not been started for a user, and a get session method once LastFM supplies a token and redirect to your callback URL. Next there are specific methods created ... More
Wednesday 09 July 2008 | 26 comments
CakePHP Ajax Drag and Drop Sorting Tutorial
I have found that CakePHP is a great alternative when Ruby on Rails is not available, and in some regards I have found it surpasses Rails. One thing that is sorely lacking though is solid documentation. Both the Docs and API listing at cakephp.org are soley lacking in useful information - and the little but important details that are left out can cause endless hours of frustration for the developer new to Cake. I spent the bulk of the day trying to figure out something that woul... More
