2005-04-03 10:52:05 +00:00
|
|
|
class Post < ActiveRecord::Base
|
2005-11-03 09:06:42 +00:00
|
|
|
belongs_to :author, :extend => Module.new {
|
|
|
|
def greeting
|
|
|
|
"hello"
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
has_many :comments, :order => "body", :extend => Module.new {
|
|
|
|
def find_most_recent
|
|
|
|
find(:first, :order => "id DESC")
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2005-11-04 19:39:50 +00:00
|
|
|
has_one :very_special_comment
|
|
|
|
has_many :special_comments
|
2005-11-03 09:06:42 +00:00
|
|
|
|
2005-04-10 17:24:56 +00:00
|
|
|
has_and_belongs_to_many :categories
|
2005-07-03 08:21:22 +00:00
|
|
|
has_and_belongs_to_many :special_categories, :join_table => "categories_posts"
|
2005-07-22 20:05:42 +00:00
|
|
|
|
|
|
|
def self.what_are_you
|
|
|
|
'a post...'
|
|
|
|
end
|
2005-04-10 15:49:49 +00:00
|
|
|
end
|
|
|
|
|
2005-07-03 08:21:22 +00:00
|
|
|
class SpecialPost < Post; end;
|
|
|
|
|
|
|
|
class StiPost < Post
|
|
|
|
has_one :special_comment, :class_name => "SpecialComment"
|
|
|
|
end
|