Don’t you know that minitest also have a similar let() helper that does exactly the same job as the one of RSpec. But some people do not fully understand the difference between defining object in let() and before() block.
How to Install Ruby 2.0 on OSX 10.7 or Newer
This short tutorial, I will show you how to install Ruby 2.0.0 on OSX 10.7+ or newer
How to Block Old IE Version With Rails
There are many ways to detect browser agent, it could be front-end side with Javascript or backend. In this short tutorial, I’ll walk you through on how to detect browser version with Ruby On Rails
This applies for Rails > 2.x
How to Setup Rails App With Puma and Nginx
In this tutorial, I’ll walk you through the concept behind using puma + nginx, plus thorough instructions on setting them up on CentOS and Ubuntu.
Install Ubuntu With PXE via OSX
In this tutorial, I’ll guide you through how to to setup OSX as PXE server to install Ubuntu on other hosts.
Debug Your Failed Test in Travis CI
Ever wondering why some tests passed locally but failed on Travis? Ever questioning how could I go about to debug why that failed test on remote Travis? Read on as I show you how
Install Postgres.app on OSX 10.7+

Traditionally, pogstgresql is installed manually with MacPort or Homebrew on Mac OSX 10.7+. I used to have lots of problem with the setup for the installation as it requires Xcode, this libs and that libs, etc. In summary, it is not convenient enough and I want something as simple as dragging an OS app to my /Application. Thanks to Heroku, they took the heed and create Postgres.app. A wrapper bundled with binary postgresql server. It is not only easy to install but also easy to setup config file if you are using Rails.
Spree 1.1 Deployment on Heroku
In this tutorial, I will show you how to create a Spree application on your local box, configure and push it to Heroku.
Install Ghostscript on Heroku Cedar
In this tutorial, I will show you how to install ghostscript on Heroku Cedar.
As you might have known that Heroku virtual machine does come with a system-wide
ghostscript version which is located at /usr/bin/gs. You can find out the
location of this version:
1 2 3 | |
However, explicit dependencies is not recommended, you could read 12 Factor Approach on dependencies at http://www.12factor.net/dependencies. Credit to Ryan Daigle who pointed it out for me and I agree with him.
To install ghostscript, we fetch the source under heroku console, fetch the source, configure and compile the software:
1 2 3 4 5 6 7 | |
You might notice that I only specify configuration parameters --with-drivers=FILES.
It is because I don’t need printer drivers for my app which only does think like
images and PDF manipulation.
Once the compilation is completed, copy the binary ghostscript-9.05/bin/gs to ~/bin.
All binaries in ~/bin will be available for your Heroku app now. You can verify
if the binary works by:
1 2 | |
And please do not forget to clean up:
1 2 | |
If you feel lazy, you could download my Ruby-wrapper of gs at https://github.com/joneslee85/ruby-ghostscript.
Exposing ActiveRecord Model Attributes to Liquid Dynamically
Liquid is a powerful templating tool especially when
used with rails. It is quite common that you have to expose ActiveRecord attributes
to liquid. You can achieve that by implement to_liquid method in your ActiveRecord
model so it acts as if it were Liquid::Drop, OR you can use the helper liquid_methods
to tell which attributes / call-able methods of the instance that could be passed
with the liquid_methods call. In most of cases, people tend to use the latter method
because they could narrow the exposure scope to liquid.
However, what if your model has so many attributes and typing all them out for
the liquid_methods seems arduous, you can dynamically mapping attributes by
creating a module:
1 2 3 4 5 6 7 8 9 | |
And you also need to include the above module in the ActiveRecord classes that you want to be exposed to Liquid:
1 2 3 4 | |
Hope you enjoy this tutorial. Comments and feedbacks are greatly welcomed :)