Sha256: 9246a67fb53ba271f30e3ad582f04b3155fd623cb7092bac5dafa5b45c9a8e07

Contents?: true

Size: 544 Bytes

Versions: 79

Compression:

Stored size: 544 Bytes

Contents

class Topic < ActiveRecord::Base
  has_many :replies, :dependent => :destroy, :foreign_key => "parent_id"
  serialize :content
  
  before_create  :default_written_on
  before_destroy :destroy_children

  def parent
    Topic.find(parent_id)
  end
  
  # trivial method for testing Array#to_xml with :methods
  def topic_id
    id
  end

  protected
    def default_written_on
      self.written_on = Time.now unless attribute_present?("written_on")
    end

    def destroy_children
      self.class.delete_all "parent_id = #{id}"
    end
end

Version data entries

79 entries across 79 versions & 6 rubygems

Version Path
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/topic.rb
jstorimer-deep-test-1.4.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/topic.rb
jstorimer-deep-test-1.3.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/topic.rb
jstorimer-deep-test-1.2.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/topic.rb
jstorimer-deep-test-1.1.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/topic.rb
jstorimer-deep-test-1.0.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/topic.rb
jstorimer-deep-test-0.2.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/topic.rb
jstorimer-deep-test-0.1.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/topic.rb
activerecord-1.15.0 test/fixtures/topic.rb
activerecord-1.15.4 test/fixtures/topic.rb
activerecord-1.15.1 test/fixtures/topic.rb
activerecord-1.15.2 test/fixtures/topic.rb
activerecord-1.15.3 test/fixtures/topic.rb
activerecord-1.15.6 test/fixtures/topic.rb
activerecord-1.15.5 test/fixtures/topic.rb
activerecord_authorails-1.0.0 test/fixtures/topic.rb
backlog-0.0.0 vendor/rails/activerecord/test/fixtures/topic.rb
backlog-0.0.1 vendor/rails/activerecord/test/fixtures/topic.rb
backlog-0.0.2 vendor/rails/activerecord/test/fixtures/topic.rb
backlog-0.0.4 vendor/rails/activerecord/test/fixtures/topic.rb