Show only published draft versions to users (and also drafts to admins)

This commit is contained in:
Amaia Castro
2017-01-03 22:08:54 +01:00
parent 3ba6b409aa
commit f040759693
5 changed files with 69 additions and 9 deletions

View File

@@ -10,6 +10,8 @@ class Legislation::DraftVersion < ActiveRecord::Base
validates :body, presence: true
validates :status, presence: true, inclusion: { in: VALID_STATUSES }
scope :published, -> { where(status: 'published').order('id DESC') }
before_save :render_html
def render_html