Class: BlogPost

Inherits:
ActiveRecord::Base
  • Object
show all
Extended by:
FriendlyId
Defined in:
app/models/blog_post.rb

Overview

@Name :BlogPost model

@Created at :12-06-2012
@Updated at  :12-06-2012
@Purpose :Needed for initailizing activerecord for blog_posts table in rails
@Company : Mindfire Solutions

Defined Under Namespace

Modules: CommentSetting

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.comments_allowed?Boolean

Returns:

  • (Boolean)


63
64
65
66
67
# File 'app/models/blog_post.rb', line 63

def comments_allowed?
#      RefinerySetting.find_or_set(:comments_allowed, true, {
#        :scoping => 'blog'
#      })
end

.next(current_record) ⇒ Object



57
58
59
60
61
# File 'app/models/blog_post.rb', line 57

def next current_record
  self.send(:with_exclusive_scope) do
    where(["published_at > ? and draft = ?", current_record.published_at, false]).order("published_at ASC")
  end
end

.uncategorizedObject



69
70
71
# File 'app/models/blog_post.rb', line 69

def uncategorized
  BlogPost.live.reject { |p| p.categories.any? }
end

Instance Method Details

#live?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'app/models/blog_post.rb', line 51

def live?
  !draft and published_at <= Time.now
end