Tag Archives: rails

Enumerable Anti-Patterns

Enumerable methods are one of my favorite parts of Ruby. Enumerable anti-patterns, however, can make things not-so-fun. Let’s explore some ways these helpful tools are abused, and how to fix them. Enumerable anti-patterns #1: Don’t use a shovel as a … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment

How I Test Controllers

I’ve been trying to improve the specs I write lately. My method before was mostly copying and pasting from my past projects. Somewhere way back I adapted them from an early version of Michael Hartl’s Rails Tutorial, making various modifications … Continue reading

Posted in Uncategorized | Tagged , , , , | Leave a comment

Lessons Learned about Timestamps

I ran into an extremely frustrating issue lately where some Rails code periodically behaved in a very unexpected way. After trying everything I could think of, I ran some code in the console to list the occurrences of the behavior, … Continue reading

Posted in Uncategorized | Tagged , , , , , , | Leave a comment

Generators in Rails 2.3

The other day I started looking in to how to create generators in Rails 2.3. I came across a couple of articles on the topic that provided a good starting point, still was a bit confused about a couple things. … Continue reading

Posted in Uncategorized | Tagged , , | Leave a comment

Rails Conventions – Singular or Plural?

So you probably know that Rails typically uses a singular name for models, e.g., User, and plural names for controllers, like UsersController. But what about other things you’re likely to encounter? Here’s a handy cheat sheet. Controller Plural rails g … Continue reading

Posted in Uncategorized | Tagged | 2 Comments

Override a Model’s destroy Method Without Losing Callbacks

I needed to do this in Rails 2, and had trouble finding any anything about how it could be done. I did eventually find some information, so I thought I’d share. Here’s how it looked for me:

  Also … Continue reading

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Working in Rails 2 & 3 with rvm

I had wanted to play with Rails 2 a bit, without breaking any of the Rails 3 apps I’m working on. I use rvm anyway, so I thought it would be pretty straightforward. I found instructions for setting it up, … Continue reading

Posted in Uncategorized | Tagged , , , | Leave a comment