instiki/vendor/rails/activerecord/test/fixtures/topic.rb
Jacques Distler 6873fc8026 Upgrade to Rails 2.0.2
Upgraded to Rails 2.0.2, except that we maintain

   vendor/rails/actionpack/lib/action_controller/routing.rb

from Rail 1.2.6 (at least for now), so that Routes don't change. We still
get to enjoy Rails's many new features.

Also fixed a bug in Chunk-handling: disable WikiWord processing in tags (for real this time).
2007-12-21 01:48:59 -06:00

37 lines
767 B
Ruby
Executable file

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 approved=(val)
@custom_approved = val
write_attribute(:approved, val)
end
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
def after_initialize
if self.new_record?
self.author_email_address = 'test@test.com'
end
end
end