class Post < ActiveRecord::Base

Posts written by users stored in database. All the instance methods defined here presume you are calling them on a published post.

Instance methods are undefined for draft posts.


  1. without (post)
    Return posts except the one specified.
  2. published ()
    Return posts that are published
  3. drafted ()
    Return posts that are NOT published
  4. search_by_title (title)
    Return all post that have a title that match the key you provide

Instance methods

  1. slug ()
    Returns a slug which is a URL representation of the current title.
  2. header? ()
    Returns true if a header was set by the user, false otherwise.
  3. header ()
    Returns the header Image if one is set. Returns nil otherwise.
  4. title ()
    Returns the last title that was set for this post.
  5. titles ()
    Returns an ActiveRecord::Relation of all the titles bound to this post.
  6. tags ()
    Returns an ActiveRecord::Relation of all the tags set for this post.
  7. content ()
    Returns the raw HTML content of the post. This is generated from Markdown when the user saves his post while editing it in the editor. This is the body of the post.
  8. excerpt ()
    Returns the raw HTML excerpt for this post. This is generated from the content and applies a few rules to the content.
    • Maximum length of 100 characters;
    • Will stop generating the excerpt if it meets a Heading element (h1-h6);
    • Will exclude images from the excerpt.