January 18, 2010 – 5:33 pm
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 up removing a number of I18n keys from the english translation file as your application [...]
January 15, 2010 – 11:37 am
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 of the 404 page will not happen and instead the exception will just be propagated. [...]
January 13, 2010 – 6:44 pm
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 omit the checked argument just like with ActiveRecord boolean attributes:
<%= f.radio_button(:email_activated, true) %> Yes
<%= f.radio_button(:email_activated, false) %> No
January 13, 2010 – 2:34 pm
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 the case where Rails itself is fundamentally broken or fails to respond your webserver will [...]
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 use model classes in your migrations (which in some cases can be very convenient and [...]
I was using a default scope for a model with :include and :order 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 committing this!
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 Object) and in the plugin case it is the Tagging model context attribute. As you [...]
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 on the :environment task (such as db:migrate). It is also not done if cache_classes is [...]
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 doesn’t allow you to capture standard error. I decided to write a little plugin called [...]