Category Archives: Ruby on Rails

Simplest bit.ly API implementation possible?

To use an URL shortener in your project, I would strongly recommend bit.ly. It let you set a custom URL (name) and track traffic, clicks and conversations on micro blogs. But best of all, it should be super-fast and super-stable, … Continue reading

Posted by Richard View Comments Posted in Ruby on Rails, Services Tagged , ,

Rails Development Database Setup Without Migrations

I think a lot of Rails developers have been using the db:migrate Rake task to setup new development databases. The problem with this is that over time migrations tend to grow out of sync with the code, especially if you … Continue reading

Posted by peter View Comments Posted in Ruby on Rails Tagged

Rails bug fix: ActiveRecord::Base#exists? now compatible with include scopes

I was using a default scope for a model with :include and rder options and ran into an issue with the exists? method. We have now refactored the exists? method to invoke find_initial which handles scopes correctly. Thanks Michael for … Continue reading

Posted by peter View Comments Posted in Ruby on Rails

Rails Gotcha: Global Methods can Cause ActiveRecord Attribute Methods to Never be Defined

I just ran into a sort of edge case gotcha in the interaction between the acts_as_taggable_on Rails plugin and RSpec. It turns out both libraries define a context method. In the RSpec case it is a global method (defined in … Continue reading

Posted by peter View Comments Posted in Ruby on Rails

Rails Gotcha: Eager Loading Application Classes to Make STI Work

Recent versions of Rails (2.2 and later I think) will eager load all application Ruby classes when booting up the server. However, because of issues with migrations this is not done if you are executing a Rake task that depends … Continue reading

Posted by peter View Comments Posted in Ruby on Rails

New Rails Plugin to shell out with verbose error handling

I was annoyed with the fact that when you use Ruby backticks (i.e. `some_shell_command`) to shell out to an external program and the path to the program is wrong then no exception is raised. In addition, using system and backticks … Continue reading

Posted by peter View Comments Posted in Ruby on Rails

Upgrading to Rails 2.3

We just upgraded our app from Rails 2.2.2 to Rails 2.3.2 and were able to get all our tests passing after having ironed out a number of deprecations, upgraded a few plugins, and patched a few others. Here is an … Continue reading

Posted by peter View Comments Posted in Ruby on Rails

New rake task for the Tranlsate plugin: Google Translate

We just pushed the latest addition to the Translate plugin which adds a new rake task: “rake translate:google FROM=sv TO=en”. This will translate all keys in sv.yaml using Google Translate into english and store them in en.yaml. This is a … Continue reading

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

Rake Tasks for the Translate Plugin

We’ve added two Rake tasks to the Translate plugin. The lost_in_translation rake task helps find I18n keys in lookups in your code that are missing from your default locale YAML file (i.e. config/locales/sv.yml in our case). The merge_keys Rake task … Continue reading

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

swedish_pluralize plugin: Swedish pluralization rules for Rails

For those of you looking for Swedish pluralization for Rails, I just refactored this module of ours into a plugin. You can find it on GitHub: http://github.com/newsdesk/swedish_pluralize/tree/master It’s extracted from the old swe_rails plugin by Ola Bini, which did a … Continue reading

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