method
inherited
![Moderate documentation Importance_2](https://d2vfyqvduarcvs.cloudfront.net/images/importance_2.png?1349367920)
inherited(p1)
private
Register or
log in
to add new notes.
stevo -
January 22, 2010
![Default_avatar_30](https://www.gravatar.com/avatar/16b8d429e0123bc50ba8ad27cdaa6ff4?default=http://apidock.com/images/default_avatar_30.png&size=30)
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