Skip to content

Instantly share code, notes, and snippets.

Avatar
📷
the code is like pasta, yum yum

Miłosz Sędziak Levii01

📷
the code is like pasta, yum yum
  • Bielsko-Biała
View GitHub Profile
View discriminable_model.rb
# Wouldn't it be great if you could have STI like functionality
# without needing to encode strings of class names in the database?
# Well today is your lucky day! Discriminable Model is here to help.
#
# Simply specify your models desired type column, and provide a block to
# do the discrimination. If you want the whole STI-esque shebang of properly
# typed finder methods you can supply an array of 'discriminate_types' that will
# be used to apply an appropriate type.
#
# class MyModel < ActiveRecord::Base