2005-04-03 10:52:05 +00:00
|
|
|
class Post < ActiveRecord::Base
|
2005-11-06 19:05:42 +00:00
|
|
|
belongs_to :author do
|
2005-11-03 09:06:42 +00:00
|
|
|
def greeting
|
|
|
|
"hello"
|
|
|
|
end
|
2005-11-06 19:05:42 +00:00
|
|
|
end
|
2005-11-03 09:06:42 +00:00
|
|
|
|
2005-11-06 20:39:34 +00:00
|
|
|
belongs_to :author_with_posts, :class_name => "Author", :include => :posts
|
|
|
|
|
2005-11-06 19:05:42 +00:00
|
|
|
has_many :comments, :order => "body" do
|
2005-11-03 09:06:42 +00:00
|
|
|
def find_most_recent
|
|
|
|
find(:first, :order => "id DESC")
|
|
|
|
end
|
2005-11-06 19:05:42 +00:00
|
|
|
end
|
2005-11-03 09:06:42 +00:00
|
|
|
|
2005-11-04 19:39:50 +00:00
|
|
|
has_one :very_special_comment
|
2005-11-06 20:39:34 +00:00
|
|
|
has_one :very_special_comment_with_post, :class_name => "VerySpecialComment", :include => :post
|
2005-11-04 19:39:50 +00:00
|
|
|
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
|
2006-03-16 02:10:11 +00:00
|
|
|
has_and_belongs_to_many :special_categories, :join_table => "categories_posts", :association_foreign_key => 'category_id'
|
2005-12-02 06:03:43 +00:00
|
|
|
|
|
|
|
has_many :taggings, :as => :taggable
|
2005-12-03 04:29:55 +00:00
|
|
|
has_many :tags, :through => :taggings
|
2005-12-02 06:03:43 +00:00
|
|
|
|
2006-02-09 19:37:05 +00:00
|
|
|
has_one :tagging, :as => :taggable
|
|
|
|
|
2006-01-21 23:40:20 +00:00
|
|
|
has_many :categorizations, :foreign_key => :category_id
|
|
|
|
has_many :authors, :through => :categorizations
|
|
|
|
|
2006-02-10 05:19:41 +00:00
|
|
|
has_many :readers
|
|
|
|
has_many :people, :through => :readers
|
|
|
|
|
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
|
2006-03-16 02:46:01 +00:00
|
|
|
self.abstract_class = true
|
2005-07-03 08:21:22 +00:00
|
|
|
has_one :special_comment, :class_name => "SpecialComment"
|
|
|
|
end
|
2006-03-16 02:46:01 +00:00
|
|
|
|
|
|
|
class SubStiPost < StiPost
|
|
|
|
end
|