Category: Rails

Rails 4 TurboLinks with JQuery document ready

Using JQuery’s $(document).ready() functionality seems to be broken when using’s the Rails Gem Turbolinks. However, to fix any issues you are experiencing, add the jquery-turbolinks gem to your Gemfile > gem ‘jquery-turbolinks’ Then, add the following line to your JS manifest file, typically application.js in your assets directory: //= require jquery.turbolinks After which, restart your […]

Rails Capistrano deployment: SSH, Error reading response length from authentication socket

If you’re running a rails application with capistrano and you run into the following error: Error reading response length from authentication socket When you attempt to connect via cap, for instance > cap staging deploy Then make sure you can answer the following questions with a ‘yes’ before continuing. 1) Is my private key properly […]

Rails slow on Ubuntu Virtualbox instance

I ran into an issue where a Rails 3.1 application running on Ubuntu 12.04 in a VirtualBox instance (development) was running ridiculously slow. Sometimes, before the server would register a request, it would take >5 seconds, then another 5 seconds just to load a simple view. Obviously, this is an unacceptable amount of time when […]

Rails 4.0 / Postgresql / Heroku / Connection timeout

If you attempt to deploy a new application to Heroku using Rails 4.0.0, with a default postgresql configuration in your gemfile, such as: gem ‘pg’ Then, heroku will assume you are requesting PG version 0.12.2. This causes errors. Instead, to avoid connection errors (timeout, undefined constant, etc), you need a more recent version: gem ‘pg’, […]

Rails select method with default value

When using the select form builder method in rails, for instance: f.select In conjunction with the options_from_collection_for_select method, like f.select :field, options_from_collection_for_select(@fields, ‘id’, ‘name’) Remember, there is a fourth argument in the above method, which defines the selected value, like so f.select :field, options_from_collection_for_select(@fields, ‘id’, ‘name’, @object.field)