Josh W Lewis

Josh W Lewis



Error Handling in Elixir with Plug.Exception

By Josh on May 30, 2016

I found a hidden gem last week: Plug’s exception protocol. It gives you a concise pattern for rendering errors to users in an informative way.

For example, consider some team dashboard that you want to limit access to in your Phoenix application....

Rails Unit Measurement Persistence

By Josh on March 9, 2014

I’ve worked on a few apps in the past that had some cumbersome constraints in regards to the units of measurement. Models needed to store heat transfer or fluid dynamics properties in either english or SI units. This is can be a bit of a pain, so I...

Unitwise: Ruby Unit Measurement Math and Conversion

By Josh on August 13, 2013

So, way back in Mechanical Engineering school, I learned that a very effective way to check my answers was to make sure the units worked out. For an example, consider a basic physics problem:

The average mass of an adult American male is 86 kilograms...

Rails' ActiveSupport try

By Josh on April 26, 2013

ActiveSupport has a few great Ruby extensions that I just love. One of my favorites is try.


Try is a sneaky method for handling NoMethodErrors on NilClass. If you ever get stuck writing code like this:

name = unless user.nil?


Rails Flash Messages with Twitter Bootstrap

By Josh on March 2, 2013

When building new Rails projects, I often use Bootstrap because it lets me focus more on the business logic, rather than design. Almost everytime I start one of these projects, I forget how I did flash messages the last time, and have to look at a...

Static Site Creation with Middleman

By Josh on February 10, 2013

I’ve put off building my personal website for a while. I’m a Rails developer, so it would be fairly straight forward to build a blogging application and host it somewhere. But, that seemed like a lot of overhead – content management system, database...