Class: Tag

Inherits:
ActiveRecord::Base show all
Defined in:
lib/app/models/tag.rb

Instance Method Summary collapse

Methods included from Spec::Rails::Extensions::ActiveRecord::ClassMethods

#records

Methods included from Resourceful::Serialize::Model

#serialize, #to_serializable

Methods included from Spec::Rails::Extensions::ActiveRecord::InstanceMethods

#errors_on

Instance Method Details

#feed_articlesObject



24
25
26
27
28
29
30
# File 'lib/app/models/tag.rb', line 24

def feed_articles
  Article.find :all,
               :joins => :taggings,
               :order => 'articles.created_at DESC',
               :conditions => ['taggings.tag_id=?', self.id],
               :limit      => Hubbub::Config[:items_per_feed] || 5
end

#page_articles(page = nil) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/app/models/tag.rb', line 16

def page_articles page=nil
  Article.paginate :page => page,
                   :joins => :taggings,
                   :order => 'articles.created_at DESC',
                   :conditions => ['taggings.tag_id=?', self.id],
                   :per_page      => Hubbub::Config[:items_per_page] || 10
end

#to_paramObject



12
13
14
# File 'lib/app/models/tag.rb', line 12

def to_param
  self.slug
end

#weightObject



8
9
10
# File 'lib/app/models/tag.rb', line 8

def weight
  Tagging.count :conditions => "tag_id = #{self.id}"
end