Posts tagged with “rails”

Better Rails debugging with pry

Pry is an interactive console, like IRB, which can be used to pause execution and inspect the current scope in your Rails web requests or tests. I’m going to show you how simple it is to drop it into your Rails apps and get better visibility over bugs.

Read more →

An environment for working with multiple Rails projects

This post explains how I use nginx and dnsmasq in my development environment to streamline the process of working with several Rails projects.

Read more →

How I got stung by the Twitter gem and thread safety

TL;DR

If you use sferik’s Twitter gem with multiple accounts in a rails app, or a ruby app that uses concurrency in some way, then you need to be using the thread safe configuration.

Read more →

Rails migrations, and a painful lesson

The other day, one of my colleagues said something that grabbed my attention, while working on one of our biggest rails apps.

Read more →

Using project specific gemsets with Rails, RVM and Passenger

I ran into an issue the other day that was exacerbated by the fact that blog posts on the subject seemed to be out of date. Therefore, this is an attempt to bring a more up-to-date solution.

Read more →

Reset PostgreSQL auto increment value in Rails

I’ve been involved in writing a rake task to migrate an old database schema to a similar but new schema in a Rails project. The new schema was similar enough that we could carry across all the primary keys from the old tables, and it saved a lot of time to re-use them. However, the problem with doing this is that the auto increment sequence does not get updated when you add a value - you have to manually reset it.

Read more →

Testing domains with Rails and Test-Unit

I’m currently working on a Ruby on Rails project where sub-domains come into play pretty heavily. Each account created on the site has its own sub-domain, which means that there is no pre-set list. I ran into some problems when writing functional tests and integration tests with Capybara, as I had no idea how to set the current domain and assert a change in sub-domain. Fortunately, after struggling through for a couple of hours, I found the solution and I’m putting it here for the benefit of anyone else!

Read more →

Uploading files in functional tests with Rails, Paperclip and Test Unit

I’ve been tearing my hair out for a couple of hours on this, so I thought I’d log the solution for everyone else’s benefit!

Read more →

Restarting thin or passenger Rails server from Vim

I’ve set up Nginx with Phusion Passenger to run my Rails apps in a development environment, as opposed to running rails server in a terminal every time. Setting the rails environment variable to “development” means that many code changes can be automatically integrated without a server restart, but every so often a full restart is required.

Read more →