article.rb
726 Bytes
class Article < ActiveRecord::Base
belongs_to :profile
validates_presence_of :profile_id, :name, :slug, :path
acts_as_taggable
acts_as_filesystem
acts_as_versioned
# retrives all articles belonging to the given +profile+ that are not
# sub-articles of any other article.
def Article.top_level_for(profile)
self.find(:all, :conditions => [ 'parent_id is null and profile_id = ?', profile.id ])
end
# produces the HTML code that is to be displayed as this article's contents.
#
# The implementation in this class just provides the +body+ attribute as the
# HTML. Other article types can override this method to provide customized
# views of themselves.
def to_html
body
end
end