Archive for 'Uncategorized'

How to initialize an Array of Hashes in Ruby

How to initialize an array of hashes. Each value of keys within the hash will initially consist of an empty array: your_hash = Hash.new {|h,k| h[k] = [] }

Free Image Placeholder Service

Once you know the dimensions of the images (photos or graphics) you’re waiting your graphic designer or other developers to produce for you, instead of waiting for them to hand the final revisions of those images to you, you can use this free service Placehold.it Just put something like this in your HTML.

Is it Rails?

Wondering whether or not a website is running on rails? Check out Is it Rails? and let us know if the result was accurate for your site.

Using ActionMailer::Preview with Devise mailers in Rails 4.1

ActionMailer::Preview is pretty awesome and newly introduced in Rails 4.1+ It allows you to preview formatting of emails from within the browser without having to send emails just to be able to preview them in the email client. This substantially reduces the duration of each development cycle between coding and testing a modification. If you […]

What to set passenger_root and passenger_ruby paths when using RVM or rbenv

If you’re using Rails, Nginx, Passenger and RVM or rbenv and wondering what to set the passenger_root and passenger_ruby paths to in nginx.conf, here’s how to get them. Keep in mind, you’ll have to do this by reconfiguring Nginx if you switch from RVM to rbenv or vice-versa. First you must install the passenger gem […]

How to replace the init.d chef-client service with a cron

To disable chef-client from init.d (be sure you really want to do this!) Then add something like this to your crontab:

Setting up Cron jobs that call Ruby (RVM) or Shell Scripts via Bash

If you are on a unix system and want to set up a crontab (cron job) and you are using RVM, you must make sure to make bash act as if it had been invoked as a login shell by using the bash -l option. So if you were going to have a script run […]

How to modify the maximum Java Heap Size in TorqueBox gem

In order to modify the maximum Java Heap Size (or any other JAVA_OPTS) when using the TorqueBox gem, start torquebox by doing a: Look for the default JAVA_OPTS settings and set your JAVA_OPTS path. Be sure you aren’t overriding your current settings first. In my case, for TorqueBox 2.3.0, I wanted to modify the maximum […]

How to tell which ruby version your Heroku app is using

Type the following:

Error installing heroku gem

My goal is to push my rails app to Heroku. However, I wasn’t able to install the heroku gem. If you get the following error when trying to do a gem install herokuĀ –no-rdoc –no-ri After researching online there were two things that could potentially be the problem. The first is that there is that my […]