Menu

Published by
Categories: Ruby, Rails, ActiveRecord

By default it’s not possible to use a database-column called type for anything else than single table inheritance. To change this, simply use set_inheritance_column() and read_attribute():

class TypeTest < ActiveRecord::Base
  set_inheritance_column(:something_else)

  def type
    read_attribute(:type)
  end

  def type=(value)
    write_attribute(:type, value)
  end
end

Cover medium

Learn how to build SaaS applications!

I’m writing a book on building SaaS applications using Ruby on Rails. Sign up now to get a sneak peek at the outline, and an exclusive discount when it’s ready.

Thanks for checking by, mate! You're already signed up to be notified about the release of the SaaS Guidebook. In the meantime, why don't you check out the current outline of the book?

Download the outline