Sha256: f9f0f87394e523aa9fb4b012e515cc4757bf7881630ee86a2994ddf0a1ab0ee8

Contents?: true

Size: 512 Bytes

Versions: 6

Compression:

Stored size: 512 Bytes

Contents

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

  N_("Topic|Terms of service")
  N_("must be abided")
  
  before_create  :default_written_on
  before_destroy :destroy_children

  def parent
    Topic.find(parent_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

6 entries across 6 versions & 1 rubygems

Version Path
gettext-1.10.0-mswin32 test/fixtures/topic.rb
gettext-1.9.0-mswin32 test/fixtures/topic.rb
gettext-1.8.0-mswin32 test/fixtures/topic.rb
gettext-1.10.0 test/fixtures/topic.rb
gettext-1.8.0 test/fixtures/topic.rb
gettext-1.9.0 test/fixtures/topic.rb