How to add HTTP Basic Authentication to your Rails application

From time to time, it's good to deploy an early version of your application, so the client can take a look. With services like Heroku, it's super easy to deploy, but it's not good to leave the application visible to the public. HTTP Basic Authentication to the rescue Most of the PaaS providers abstract the web server from you, but even you have access to it, you can use Rails to setup basic authentication. First, create a new concern in your cont…

Keep Reading by Mirko Akov Mirko Akov

How to add Facebook like button that works with Turbolinks

After finding a solution to add Google Analytics tracking code, once again I had to face a problem that came with Turbolinks. I was not able to load the facebook script in the head of the page, to prevent it from being loaded with every single request. That's why, I decided to combine my research into a helpful CoffeeScript class. To be able to use it, you need to require the file in your application script and load them in the head section of th…

Keep Reading by Mirko Akov Mirko Akov

How to add Google Analytics tracking that works with Turbolinks

Turbolinks is a really nice way to improve your Rails 4 application's speed. It uses AJAX to load the pages and just replace the body element of your page. The official Google Analytics tracking code does not play nice with this approach, but we can easily make it work. The following code snippet is a nice and clean solution for a couple of reasons: It works nicely with Turbolinks Degrades to work even without Turbolinks enabled Uses the new trac…

Keep Reading by Mirko Akov Mirko Akov

Add syntax highlighting to Ghost with Prism.JS

We are software development company and as such, we will blog about code from time to time. I know that I would do it as I am one of the company's developers. That's why we needed to add syntax highlighting to our blog. Ghost is really nice platform (even though is not completely finished yet) and it's a breeze to extend to meet your needs. Prism.JS For syntax highlighting library, we choose Prism.JS, which is really nice and as the site says, it…

Keep Reading by Mirko Akov Mirko Akov