method
inherited
inherited(p1)
public
Register or
log in
to add new notes.
stevo -
January 22, 2010
1 thank
Interesting usage for polymorphic asset model :)
…to automatically define default scopes of inherited classes.
class Asset < ActiveRecord::Base belongs_to :resource, :polymorphic => true before_save :set_asset_type def set_asset_type self.asset_type = self.class.name end def self.inherited(subclass) super subclass.send(:default_scope, :conditions => "asset_type='#{subclass.name}'") end end