Archive for the ‘Rails’ Category

Azureus on Rails

Saturday, January 20th, 2007

Over the last few months I’ve been developing Azureus on Rails, a web interface for Azureus implemented in Ruby on Rails. The first release is now available for download at RubyForge.

For a while I had been using Strawp’s Azureus PHP Control Layer and the HTML Web UI plugin. Neither of these provided all the features I wanted though, so I developed my own. Azureus on Rails

  • displays detailed information about each torrent,
  • allows torrent and file priorities to be adjusted,
  • supports stopping, starting, pausing and removing torrents,
  • allows torrents to be uploaded or added by url
  • and has a feed of the downloading and seeding torrents

The Azureus on Rails Wiki contains the full list of supported features as well as screenshots and installation instructions.

Fixing rxml attribute escaping

Thursday, December 29th, 2005

The version of Builder used for rxml templates in Rails 1.0 doesn’t escape attribute values when they are written to the output. This means characters such as double quotes in the attribute values will cause invalid XML documents to be generated.

To avoid having to manually escape every attribute value in rxml templates, I’ve put together a plugin that fixes this issue. Download rails_fixes.zip and extract it to your vendor/plugins directory (to create a new rails_fixes directory). The plugin replaces the _insert_attributes method of Builder::XmlMarkup with one that escapes the values.

Simulating views in Ruby on Rails

Wednesday, August 17th, 2005

If you want to use views in Ruby on Rails but aren’t using a database that supports them, I’ve created a subclass of ActiveRecord::Base that can simulate selecting from a view in a normal ActiveRecord find.

The extension allows the table names in the from section of queries to be replaced with subqueries specified by ActiveRecord classes. The subqueries can do anything that can be done with a view. ActiveRecords using subqueries can be eager loaded with includes like any normal ActiveRecord. This allows group bys and aggregate functions to be used without having to write a custom find_by_sql method or load in lots of data.

Download the code and view the documentation.