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



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

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

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



46
47
48
49
50
51
52
53
54
55
# File 'app/models/blogit/post.rb', line 46

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 =


40
41
42
# File 'app/models/blogit/post.rb', line 40

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