Category Archives: Ruby on Rails

6 Ways to get More Bang for your Heroku Buck While Making Your Rails Site Super Snappy

We love Heroku. It makes deployment so easy and quick. However, it can start to get pricey when you add additional dynos at $35 each a month.

With a small amount of work, you can get a lot more out of your Heroku hosting whilst drastically improving the performance of your site. You might need to spend a little bit of cash on other services, but a lot less than if you simply moved the dyno slider up a few notches, and the result will be much better scalability.

So how do we max out the performance of our Heroku apps? First we stop using Heroku for things it’s bad at, then we let it do more of what it is good at, running your application code.


Continue reading

Rails Quick Tip: YAML output in the Rails console

You can file this in the “things I wish I’d known about years ago” pile along with the bundle open command…

If you want to dump the contents of an object on the Rails console in a nice and readable YAML format, just use the function ‘y

E.g.

> y Company.first
  Company Load (0.3ms)  SELECT "companies".* FROM "companies" LIMIT 1
--- !ruby/ActiveRecord:Company
attributes:
  id: 2
  name: Abcam
  created_at: '2012-05-31 10:58:57.070819'
  updated_at: '2012-06-27 10:47:44.662756'
  url: http://Abcam.example.com/
  state: hidden

Simple.

I’ve no idea how it’s taken me this long to find out about it, but I’m glad I finally have.

Things I’d forgotten: The ActiveRecord update_all method

This is the first of a series of short posts on little features in Rails that are occasionally useful, but easily forgotten.

Sometimes it’s easy to forget that Rails’ ActiveRecord is built on relational databases and fall into the trap of doing things with comparatively complex bits of Ruby when they could be done in one go in SQL, more easily, and faster.

Continue reading