diff --git a/app/controllers/qbrick/pages_controller.rb b/app/controllers/qbrick/pages_controller.rb index 59db76c..2e6b9ef 100644 --- a/app/controllers/qbrick/pages_controller.rb +++ b/app/controllers/qbrick/pages_controller.rb @@ -47,6 +47,7 @@ def redirect_page? def find_page_by_path @page = Qbrick::Page.published.find_by_path params[:url].to_s + raise ActionController::RoutingError, 'Not Found' if @page && !@page.published? end end end diff --git a/app/models/qbrick/page.rb b/app/models/qbrick/page.rb index f4b4f99..72cf05c 100644 --- a/app/models/qbrick/page.rb +++ b/app/models/qbrick/page.rb @@ -15,6 +15,7 @@ class Page < ActiveRecord::Base default_scope { order 'position ASC' } scope :published, -> { where locale_attr(:published) => Qbrick::PublishState::PUBLISHED } + scope :unpublished, -> { where.not locale_attr(:published) => Qbrick::PublishState::PUBLISHED } scope :translated, -> { where.not locale_attr(:path) => [nil, ''], locale_attr(:title) => [nil, ''] } scope :content_page, -> { where page_type: Qbrick::PageType::CONTENT } @@ -92,7 +93,7 @@ def without_self end def published? - published == Qbrick::PublishState::PUBLISHED + published == Qbrick::PublishState::PUBLISHED && !ancestors.unpublished.present? end def state_class