About
Hi! I'm Avdi Grimm, and this is my software development blog. More...
Books and Screencasts
Objects on Rails
A developer notebook on applying classic Object-Oriented principles to Ruby on Rails projects.
-
Subscribe
-
Recent Posts
Archives
Categories
Meta
Tag Archives: activerecord
New maintainer needed for NullDB
NullDB, for those who don’t know, is a null backend for ActiveRecord. Unlike RSpec’s stub_object, rather than raise an exception on DB access, will NullDB DB interactions simply become no-ops. This is handy for things like testing after_save hooks in … Continue reading
ActiveRecord Default Association Extensions
How to add helper methods to all associations of a given type, as well as to the model class. Continue reading
DRYing up your validations using DB reflection
Avoiding silent truncation of your model fields requires putting length validations on them. But this can introduce duplication of knowledge. In this post I demonstrate how to pull limit information directly from the DB into your model validations. Continue reading
Fowler on Rails
Projects using Ruby on Rails often lack strong distinctions in two main areas: The model/record conflation: Seeing “models” as strictly DB-backed resources. The view/template conflation: failing to draw a line between view objects and HTML templates. The conflations are encouraged … Continue reading
Posted in Ruby
Tagged activerecord, datamapper, Martin Fowler, patterns, Ruby on Rails, templates, two step view
18 Comments
ActiveRecord Golf
So I was messing around with some scratchpad code today, investigating the use of with_exclusive_scope, and here’s what I had to write to come up with a minimal working ActiveRecord model: require ‘rubygems’ require ‘active_record’ ActiveRecord::Base.establish_connection( :adapter => “sqlite3″, :database … Continue reading
Looking for a new NullDB maintainer
I love Open Source. NullDB, a weekend hack that I barely touched after its first version, continues to attract periodic forks and patches. For a long time I’ve been meaning to sit down and roll in all the contributions that … Continue reading
Posted in Uncategorized
Tagged activerecord, datamapper, floss, nulldb, oss, ruby, testing
Leave a comment
Using AlterEgo with ActiveRecord
François Beausoleil has a nice post up demonstrating “how to use AlterEgo with ActiveRecord”:http://blog.teksol.info/2008/12/09/how-to-use-alterego-with-activerecord.html. If you’re interested in introducing state-specific behaviors to your ActiveRecord objects, check it out!
Announcing NullDB 0.0.1
I spent the afternoon coding an alternative to the ARBS and UnitRecord database-elimination plugins. Definitely scratching a personal itch, as I had a project where I wanted to use one of the above-mentioned libraries but i just couldn’t seem to … Continue reading




