Class: Blogit::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/blogit/post.rb

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Object) for_index

Returns the blog posts paginated for the index page



37
# File 'app/models/blogit/post.rb', line 37

scope :for_index, lambda { |page_no = 1| order("updated_at DESC").page(page_no) }

Instance Method Details

- (Object) blogger_display_name

If there’s a current blogger and the display name method is set, returns the blogger’s display name Otherwise, returns an empty string



49
50
51
52
53
54
55
56
57
58
# File 'app/models/blogit/post.rb', line 49

def blogger_display_name
  if self.blogger and !self.blogger.respond_to?(Blogit.configuration.blogger_display_name_method)
    raise ConfigurationError, 
    "#{self.blogger.class}##{Blogit.configuration.blogger_display_name_method} is not defined"
  elsif self.blogger.nil?
    ""
  else
    self.blogger.send Blogit.configuration.blogger_display_name_method        
  end
end

- (Object) to_param

= Instance Methods =


43
44
45
# File 'app/models/blogit/post.rb', line 43

def to_param
  "#{id}-#{title.parameterize}"
end