Skip to content

Instantly share code, notes, and snippets.

require "gays"
module Configuration
def self.attributes
@attributes
end
def self.configure
base = ConfigBlock.new
# With macro
has_many :comments, :foreign_key => 'commentable_id', :conditions => "commentable_type = 'User'", :dependent => :destroy
# Without macro
def comments
Comment.all(:conditions => {:commentable_id => self.id, :commentable_type => 'User'})
end
before_destroy :remove_associated_comments