Ruby on Rails

Posts tagged with 'Ruby on Rails':

Rails testing miniseries part 6: View testing

View testing allows you to test out complicated or critical view code, but has probably the lowest payoff in terms of problems prevented per developer minute spec.

More

Rails application testing, top to bottom

Intro to a mini-series of articles with advice and pointers on practical, pragmatic testing for Ruby on Rails applications, based on my recent WellRailed presentation on the subject.

More

Rails testing miniseries part 2: What we want to test

Before we can get stuck into how to test each bit of our application, we need to be clear about what we need to cover.

More

Rails testing miniseries part 3: MVC testing

In MVC testing we test that each of parts of our application behave. Testing them separately makes our tests faster to write, faster to run, and reduces rework when we make changes to the app. Covers when to write the tests, and Test::Unit vs. RSpec.

More

Rails testing miniseries part 5: Controller testing

In Rails apps the main intelligence is supposed to live in the model. As a result, testing properly-designed controllers should mostly be just testing that things are glued together correctly; if your app's factored well, it should be simple and quick to do.

More

Installing ruby postgres and mysql gems on Leopard

Leopard comes with ruby preinstalled. Most of us use macports to install postgresql & mysql for use with rails, but if you use macports to install their ruby bindings then it will build it's own ruby too. That works, but here's how to compile them if you'd prefer to stick to the stock Leopard ruby.

More

Ruby memcache-client reconnect and retry-once patch

A big problem we hit with the Ruby memcache-client library (1.5.0) is that if the memcache server connection dies, it leaves the mongrel permanently broken. I've written a big patch to refactor it to reconnect properly and also retry the request (once) to give it a fresh start.

More

CruiseControl.rb git support patches

I've published a set of patches for CruiseControl.rb to fix up some issues with its' git support, and add full log parsing including messages and changesets, so your notifiers etc. can show the full info as for SVN. You can grab my patches from the Lighthouse ticket or pull from my github master. Thanks to my client Youdo for supporting this work!

More

Rails 2.1 eager loading conditions hash bugfix

I've created Rails lighthouse ticket #1101 for a blatant 2.1.x bug breaking :including of associations that have :conditions hashes. My patch is on the ticket. Remember to +1 it so it gets merged.

Permalink

Rails 2.1 eager loading doubleup bug

I've created Rails lighthouse ticket #1110 for another bug in the new 2.1.x association preloading code that was causing some has_manys to get loaded with two copies of each record in the collection (and less seriously, double SQL loads of all types of collections). The problem turned out to be triggered by associations that have :includes defined on them themselves when the :includes are also supplied in the find call. My patch is on the ticket. +1s welcome :).

Permalink

ERB comments in Ruby 1.8.7

After upgrading my server to Ubuntu Intrepid I found that this Rails site's layouts broke. The problem is this issue resulting from a ERB code change in Ruby 1.8.7: if you put a # Ruby comment in a one-line <% %> block, all the content up to the next %> that's on a subsequent line is ignored.

More

db:schema:dump after db:migrate:redo Rails patch

I've submitted another patch to Rails for a minor-but-annoying bug – if you use db:migrate:redo you'll find that it does migrate correctly but the schema dump afterwards doesn't work, so db:test:prepare clones the wrong structure (for example). The patch fixes things so that second and subsequent db:schema:dump invocations work properly. Testing and +1s, as always, very welcome.

Permalink

script/dbdump command for Rails

I've just published a tiny Ruby on Rails plugin that adds a script/dbdump command. Like script/dbconsole, it reads your database configuration from config/database.yml and runs the appropriate mysql/postgresql/sqlite program – but rather than running up a database console it does a database dump. See the README at the above page re password options.

Permalink

Rails Range conditions patch

I've submitted a patch to add support for Ruby's end-exclusive Range objects (created using … instead of ..) in ActiveRecord find :conditions hashes. This is really useful if you want to break apart a series of objects on something like a date-time field, which doesn't quantize exactly to integer values (on all databases) and so can't be handled using non-exclusive ranges without overlaps from values exactly on the boundary.

Permalink

Rails columns on demand plugin

I've extracted out the code I was using to lazily load large BLOB/TEXT columns in one of my projects, tidied it up to take advantage of a refactoring in Rails 2.2.2 (cheers Koz) and improve its semantics, and released it as the columns_on_demand plugin.

More

Installing PostgreSQL and Mysql and the Ruby gems on Snow Leopard

Things have gotten a lot simpler since the write-up I gave for Leopard.

Again, Snow Leopard comes with Ruby preinstalled, and I strongly recommend that you stick with that version rather than using the macports Ruby – no need to have two versions on your system.

More