Category Archives: Ruby on Rails

Testbot – Distributed testing

TL;DR If you have a lots of tests in a rails app that is annoyingly slow (+10 minutes), try testbot – a tool for distributed testing Testbot What? Testbot is a tool for running tests distributed over several machines. Mynewsdesk … Continue reading

Posted by Kristian Hellquist View Comments Posted in Ruby on Rails, Testing Tagged , ,

Migrating RSpec to Mocha

I have been using the builtin RSpec mocking framework for a couple of years and haven’t had any issues with it. The one feature I have been missing though is the any_instance method of the Mocha framework. What this method … Continue reading

Posted by peter View Comments Posted in Ruby on Rails Tagged ,

PostgreSQL Unreliable Default Sort Order and Random Rails Test Failures

We have been struggling with intermittent Rails test failures for quite some time. There were times when we blamed our search engine Ferret, sometimes we blamed database interference between tests, and sometimes higher powers. Lately we have realized that all … Continue reading

Posted by peter View Comments Posted in Ruby on Rails

Rails 2.3.2 Bug – Sending Multipart Email Breaks When Current Directory is not RAILS_ROOT

We had the debugging session of the year here at Newsdesk the other day and we thought it would be prudent to warn other people about it. It turns out that ActionMailer in Rails 2.3.2 fails in sending multipart emails … Continue reading

Posted by peter View Comments Posted in Ruby on Rails

Enabling/Disabling the Rails Cache

We needed a way to globally enable/disable the Rails cache so we came up with this patch: By default ActionController will use the Rails.cache (RAILS_CACHE) object configured by config.cache_store for its fragment caching (action caching is an around filter that … Continue reading

Posted by peter View Comments Posted in Ruby on Rails

Announcing Cachable Model – A New Plugin For Caching Your Rails Models

When you scale a Rails website the database layer tends to become the bottleneck sooner or later as it’s more difficult to scale horizontally with hardware than the Ruby/web server layer. At MyNewsdesk we have started looking at database caching … Continue reading

Posted by peter View Comments Posted in Ruby on Rails Tagged ,

Keep Your I18n Translation Files Tidy

I added the Rake task translate:remove_obsolete_keys that lets you remove all obsolete translations from your YAML files. How is a translation rendered obsolete? Suppose you are translating from english to a number of other languages. Over time you may end … Continue reading

Posted by peter View Comments Posted in Ruby on Rails

Configuring Exception Handling in RSpec and Controller Tests

The ActionController::Rescue module in Rails defines a number of exceptions that will trigger a 404 response, namely ActionController::RoutingError, ActionController::UnknownAction, and ActiveRecord::RecordNotFound. However if you trigger one of those exceptions in a controller test (Test::Unit or Rspec) then rescue and display … Continue reading

Posted by peter View Comments Posted in Ruby on Rails, Services

acts_as_bitfield Plugin now Radio Button Compatible

I’ve patched the acts_as_bitfield plugin to recognize “true” as true so that now instead of having to write: <%= f.radio_button(:email_activated, true, :checked => (“checked” if @item.email_activated?)) %> Yes <%= f.radio_button(:email_activated, false, :checked => (“checked” unless @item.email_activated?)) %> No you can … Continue reading

Posted by peter View Comments Posted in Ruby on Rails, Uncategorized

Rails I18n and 404/500 Error Pages

If you have a multilingual site it makes sense for your 404 and 500 error pages to be multilingual as well. Rails supports multilinguality by serving up error pages with a path like public/500.sv.html, where sv is the locale. In … Continue reading

Posted by peter View Comments Posted in Ruby on Rails, Services