Last active
May 21, 2017 12:22
Revisions
-
chrisdpeters revised this gist
Jul 30, 2014 . 1 changed file with 11 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ class Admin::PostsController < Admin::BaseController def index @posts = Post.live.includes(:draft).to_a @posts.map! { |post| post.draft? ? post.draft.reify : post } end def show @post = Post.live.find(params[:id]) @post = @post.draft.reify if @post.draft? end end -
chrisdpeters revised this gist
Jul 30, 2014 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ # Accessing drafts through the `Draftsman::Draft` class @drafts = Draftsman::Draft.order(:created_at) # Accessing a draft through a model @post = Post.find(params[:id]) @draft = @post.draft if @post.draft? -
chrisdpeters created this gist
Jul 30, 2014 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ Widget.drafted # Limits to items that have drafts. Best used in an "admin" area in your application. Widget.published # Limits to items that have been published at some point in their lifecycles. Best used in a "public" area in your application. Widget.trashed # Limits to items that have been drafted for deletion (but not fully committed for deletion). Best used in an "admin" area in your application. Widget.live # Limits to items that have not been drafted for deletion. Best used in an "admin" area in your application.