if defined?(ActiveRecord)
  ActiveRecord::Base.class_eval do
    def self.has_many_kindeditor_assets(*args)
      options = args.extract_options!
      asset_name = args[0] ? args[0].to_s : 'assets'
      class_name = self.name
      # Time 2015-04-01 14:20:32
      # Author lizanle
      # Description  对象类型对应的数值，kindeditor_assets表里owner_type的值

      has_many asset_name.to_sym,
               :class_name => 'Kindeditor::Asset',
               :conditions => "owner_type = #{('OwnerTypeHelper::'+class_name.upcase).constantize}",
               :foreign_key => 'owner_id', :dependent => options[:dependent]
    

      Kindeditor::Asset.class_eval do
        belongs_to :owner, :class_name => class_name, :foreign_key => 'owner_id'
      end
    end
  end
end