app/models/spud_post.rb in spud_blog-0.9.9 vs app/models/spud_post.rb in spud_blog-0.9.10

- old
+ new

@@ -6,10 +6,11 @@ :join_table => 'spud_post_categories_posts', :foreign_key => 'spud_post_id' belongs_to :author, :class_name => 'SpudUser', :foreign_key => 'spud_user_id' has_many :comments, :class_name => 'SpudPostComment' has_many :visible_comments, :class_name => 'SpudPostComment',:conditions => {:spam => [nil,false]} + has_many :spam_comments, :class_name => "SpudPostComment", :conditions => {:spam => true} has_many :spud_permalinks,:as => :attachment has_many :spud_post_sites, :dependent => :destroy scope :publicly, where('visible = true AND published_at <= ?', Time.now.utc).order('published_at desc') scope :future_posts, where('visible = true AND published_at > ?', Time.now.utc) @@ -75,9 +76,10 @@ records = SpudPost.select('Extract(Month from published_at) as published_month, Extract(Year from published_at) as published_year').where('visible = ? AND published_at < ?', true, DateTime.now).group('published_month, published_year').order('published_year desc, published_month desc') begin return records.collect{ |r| Date.new(r[:published_year].to_i, r[:published_month].to_i) } rescue Exception => e logger.fatal "Exception occurred while fetching post archive dates:\n #{e.to_s}" + return [] end end def self.months_with_public_news_posts records = SpudPost.select('Extract(Month from published_at) as published_month, Extract(Year from published_at) as published_year').where('visible = ? AND published_at < ? AND is_news = ?', true, DateTime.now, true).group('published_month, published_year').order('published_year desc, published_month desc')