Posts Tagged ‘activerecord’

Class inherits from

Posted in Home on August 3rd, 2008 by mark – 2 Comments

I wanted to know if a class was an Active Record class. I couldn’t find an easy way to do it in Ruby so I monkey patches the Class object like so (assuming Person is an active record model object).

class Class
  def inherits_from?(klass, me=self)
    return false if me.nil?
    return true if me == klass
    inherits_from? klass, me.superclass
  end
end

>> Person.inherits_from? ActiveRecord::Base
=> true

activerecord-postgresql-adapter in Rails 2.1

Posted in Home on July 13th, 2008 by mark – 1 Comment

If you get the following message

Please install the postgresql adapter: `gem install activerecord-postgresql-adapter`

It means you don’t have the new ‘pg’ postgresql library installed. This is easily fixed with a bit of

sudo gem install pg