Module: Thesis::ControllerHelpers

Included in:
ThesisController
Defined in:
lib/thesis/controllers/controller_helpers.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



9
10
11
12
13
14
# File 'lib/thesis/controllers/controller_helpers.rb', line 9

def self.included(base)
  raise ActiveRecordRequired.new("Currently, Thesis only works with ActiveRecord.") unless defined? ActiveRecord

  # base.extend ClassMethods
  # base.helper_method :class_method_here
end

Instance Method Details

#current_pageObject



16
17
18
# File 'lib/thesis/controllers/controller_helpers.rb', line 16

def current_page
  @current_page ||= Page.where(slug: request.fullpath).first
end

#page_is_editable?(page) ⇒ Boolean

Returns:

  • (Boolean)

Raises:



24
25
26
# File 'lib/thesis/controllers/controller_helpers.rb', line 24

def page_is_editable?(page)
  raise RequiredMethodNotImplemented.new("Add a `page_is_editable?(page)` method to your controller that returns true or false.")
end

#root_pagesObject



20
21
22
# File 'lib/thesis/controllers/controller_helpers.rb', line 20

def root_pages
  @root_pages ||= Page.where(parent_id: nil).order("sort_order ASC").all
end

#thesis_editorObject



28
29
30
# File 'lib/thesis/controllers/controller_helpers.rb', line 28

def thesis_editor
  "<div id='thesis-editor'></div>".html_safe if page_is_editable?(current_page)
end