Posts tagged activerecord


Database Versioning

databases activerecord sequel datamapper | comments

Migrations bother me.

On one hand, migrations are the best solution we have for the problem of versioning databases. The scope of that problem includes merging schema changes from different developers, applying schema changes to production data, and creating a DRY representation of the schema.

Continue reading »


ActiveRecord Migrations Outside Rails

activerecord databases sinatra | comments

To use ActiveRecord’s migrations with Sinatra (or other non-Rails project), add the following to your Rakefile:

Continue reading »


Database URLs

activerecord databases datamapper sequel | comments

DataMapper and Sequel both use urls for configuring database connections:

Continue reading »



activerecord rest | comments

When serving up an ActiveRecord as resource, you can use options like :only and :except to to_xml. But in most cases, you want the same fields served every time - on create, update, and get. So put the options into the class itself:

Continue reading »


ActiveRecord Setter Overloading

rails activerecord | comments

When overloading an ActiveRecord setter, I’ve often done this:

def name=(new_name) @old_name = name attributes['name'] = new_name end Continue reading »