Sha256: d8fb6fc82eb7016edc7d945de68c1af85e137fb59736adb8b40ff265b1850e48

Contents?: true

Size: 680 Bytes

Versions: 1

Compression:

Stored size: 680 Bytes

Contents

# The Commenting join model. This model is automatically generated and added to your app if you run the commenting generator.

class Commenting < ActiveRecord::Base 
 
  belongs_to :<%= parent_association_name -%><%= ", :foreign_key => \"#{parent_association_name}_id\", :class_name => \"Comment\"" if options[:self_referential] %>
  belongs_to :commentable, :polymorphic => true
  
  # This callback makes sure that an orphaned <tt>Comment</tt> is deleted if it no longer tags anything.
  def before_destroy
    <%= parent_association_name -%>.destroy_without_callbacks if <%= parent_association_name -%> and <%= parent_association_name -%>.commentings.count == 1
  end    
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
has_many_polymorphs-2.11 generators/commenting/templates/commenting.rb