Sha256: 8228bc8bbee4a023a0983e0979bd347a10c2bd98e1cce662265f18a634309924

Contents?: true

Size: 820 Bytes

Versions: 26

Compression:

Stored size: 820 Bytes

Contents

class SeriesStatementRelationship < ActiveRecord::Base
  attr_accessible :child_id, :parent_id
  belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'SeriesStatement'
  belongs_to :child, :foreign_key => 'child_id', :class_name => 'SeriesStatement'
  after_save :reindex
  after_destroy :reindex

  validates_presence_of :parent_id, :child_id
  validates_uniqueness_of :child_id, :scope => :parent_id
  acts_as_list :scope => :parent_id

  def reindex
    parent.try(:index)
    child.try(:index)
    Sunspot.commit
  end
end

# == Schema Information
#
# Table name: series_statement_relationships
#
#  id         :integer          not null, primary key
#  parent_id  :integer
#  child_id   :integer
#  position   :integer
#  created_at :datetime         not null
#  updated_at :datetime         not null
#

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
enju_biblio-0.1.0.pre36 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre35 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre34 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre33 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre32 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre31 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre30 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre29 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre28 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre27 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre26 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre25 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre24 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre23 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre22 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre21 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre20 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre19 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre18 app/models/series_statement_relationship.rb
enju_biblio-0.1.0.pre17 app/models/series_statement_relationship.rb