Menu

Hugh

Dealing with Missing Data on the Frontend

What if you got an unexpected result from an ActiveRecord query? If it’s important for the current page, rendering a 500 is a good idea. If the data is being used for a non-vital section, it’s best to render the page without the section: @manager = Manager.find(params[:id]) rescue nil <div id=”sidebar”> <% if @manager.nil? %> […]

March 21, 2011

Tony Chen

Factory > Fixtures

In general, using fixtures in testing is a big no no. Not only does it become a maintenance nightmare, it can also significantly slow down your test suite. Instead, the general practice should be to build out factories. I personally like using machinist for its terse syntax, but because our front end stack relies on […]

December 17, 2010

Tony Chen

Models, they make everything look good

One of the most common best practices in Rails is to keep the controller light weight. This helps maintain the code’s readability maintainability, and refactorability (just like coding, I make stuff up). This is often done by pushing as much of the business logic as you can (where it still makes sense) down into a […]

August 31, 2010