Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/qbrick/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 && [email protected]?
end
end
end
3 changes: 2 additions & 1 deletion app/models/qbrick/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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
Expand Down