Tag Archives: Rails

Versioning REST Web Services (Tricks and Tips)

In my previous post on this subject I described an approach to versioning the API of a REST/HTTP web service. This approach has significant advantages over the approach that is currently most common (i.e. embedding a version token in the URL). However, it does have some downsides. This post is an attempt to outline those and […]

ActiveRecord race conditions

Ara Howard has discovered that the ActiveRecord validation mechanism does not ensure data integrity.1 Validations feel a bit like database constraints but it turns out they are really only useful for producing human friendly error messages. This is because the assertions they define are tested by reading from the database before the changes are written to the database. As you […]

Things to be Suspicious Of — attr_accessor_with_default with a collection

My team ran into this problem yesterday where the a particular, very important, request was failing in one of our Rails apps. The failure did did not make much sense and even more confusingly, the same code worked perfectly in the console. As part of debugging the problem we restarted the mongrel cluster, and suddenly everything worked […]

Decouple the File in your Rails Plugin, Please

Defining new behavior for core Rails classes in mixins is a common pattern in Rails plugins. This allows for a separation of concerns that improves maintainability and digestability. However, it raises a bit of question about where the mixin inclusion step should take place. Should it happen in the plugin’s init.rb or in the same file as […]

Hierarchical Resources in Rails

Consider a situation where you have a type of resource which always belongs to a resource of another type. How do you model the URI space using Rails? For example, say you have an address resource type. An address is always associated with exactly one user, but a user may have several addresses (work, home, etc). The simple […]

Rake is Sweet

Rake is a really excellent build tool. It is basically Make on steroids (and minus a few of the annoying inconveniences of make). If you build software of any sort you owe it to yourself to check out Rake. The source of my Rake related euphoria today is that I just used a feature of Rake that is […]

Even the errors are happy making

This has got to be my favorite RoR error message: 1) Error: test_truth(Admin::EscalationMgt::EscalationViewsControllerTest): ArgumentError: Admin::EscalationMgt is not missing constant EscalationViewsController! Only in Rails would the fact that you are trying to use a constant that does exist be an error.

My New Job

I have been at my new job for just over a month now so I suppose it is time to post something about it. I joined Absolute Performance at the end of November. We do “operations management solutions” which is marketing speak for helping you — both reactively and proactively – keep your applications, and systems, available […]

DrySQL: Not All I Had Hoped

I happened upon DrySQL the other day and I was immediately interested. DrySQL is an add-on to the standard ActiveRecord support in Rails that uses a lot more of the meta-data in the database to generated the model classes. The standard ActiveRecord classes basically just use the column names to create accessor and modifier methods for the models. […]

HTTP Is All You Need

Mr. Davidson saying that “FastCGI is weak sauce” and HTTP is were it’s at. Damn right. I am glad to see the Rails community is coming realizing the power of HTTP.