Class: Tenon::PagesController

Inherits:
ResourcesController show all
Defined in:
app/controllers/tenon/pages_controller.rb

Instance Method Summary collapse

Methods inherited from ResourcesController

#destroy, #edit, #initialize

Constructor Details

This class inherits a constructor from Tenon::ResourcesController

Instance Method Details

#createObject



29
30
31
32
33
# File 'app/controllers/tenon/pages_controller.rb', line 29

def create
  params[:page][:creator_id] = current_user.id
  params[:page][:updater_id] = current_user.id
  super
end

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/tenon/pages_controller.rb', line 5

def index
  respond_to do |format|
    format.html
    format.json do
      if params[:q].blank?
        @pages = Tenon::Page.order(:lft)
      else
        pages = Tenon::Page.where(search_args).map { |p| [p.ancestors, p] }
        @pages = pages.flatten.uniq.sort_by(&:lft)
      end
    end
  end
end

#newObject



19
20
21
22
# File 'app/controllers/tenon/pages_controller.rb', line 19

def new
  resource.parent_id = params[:parent_id]
  super
end

#reorderObject



35
36
37
38
# File 'app/controllers/tenon/pages_controller.rb', line 35

def reorder
  @pages = Tenon::Page.reorder!(params[:item_list], params[:parent_id])
  render nothing: true
end

#updateObject



24
25
26
27
# File 'app/controllers/tenon/pages_controller.rb', line 24

def update
  resource.updater_id = current_user.id
  super
end