Uģis Ozols

Code and other bla


Pry and rescue

In this short post I'm going to share a tip on one of the ways I use pry. If you don't know what pry is here's how it is described on the official website: Pry is a powerful alternative to the standard IRB shell for Ruby. It features syntax highlighting, a flexible plugin architecture, runtime invocation and source and documentation bro…

Uģis OzolsUģis Ozols

Adding slug support to Phoenix models

As I'm building elixirpipe.com I had a need to add slug support to a couple models. Well, it wasn't really a need but more of liking of urls like /posts/awesome-post-title instead of /posts/1. I'm going to use the same principle described in Programming Phoenix book but with one difference. I'm going to use a package called slugger to gen…

Uģis OzolsUģis Ozols

How to add SASS/SCSS support to Phoenix

As of this writing Phoenix is at version 1.0.3 and it doesn't come out of the box with SASS/SCSS support. I'm assuming your Phoenix application is using brunch so adding SASS/SCSS support is trivial. Open package.json which is located in the root directory of your Phoenix application and add sass-brunch dependency. Currently sass-brunch n…

Uģis OzolsUģis Ozols

Rails.root equivalent in Phoenix

The other day I was looking for a way to get a root path of my Phoenix application. In Rails we have Rails.root so I was hoping to find something similar in Phoenix. Clicking on the first Google search result I was taken to https://groups.google.com/forum/#!topic/phoenix-talk/CF_bewpnbsM where Chris McCord pointed to :root option in the E…

Uģis OzolsUģis Ozols