Class: Admin::PagesController

Inherits:
ResourceController
  • Object
show all
Defined in:
app/controllers/admin/pages_controller.rb

Defined Under Namespace

Classes: PreviewStop

Instance Method Summary collapse

Instance Method Details

#editObject



37
38
39
40
41
42
# File 'app/controllers/admin/pages_controller.rb', line 37

def edit
  assets = Asset.order('created_at DESC')
  @term = assets.ransack(params[:search] || '')
  @term.result(distinct: true)
  response_for :edit
end

#indexObject



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

def index
  @homepage = Page.find_by_parent_id(nil)
  response_for :plural
end

#newObject



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

def new
  assets = Asset.order('created_at DESC')
  @term = assets.ransack(params[:search] || '')
  @page = self.model = model_class.new_with_defaults(trusty_config)
  assign_page_attributes
  response_for :new
end

#previewObject



44
45
46
47
48
# File 'app/controllers/admin/pages_controller.rb', line 44

def preview
  render_preview
rescue PreviewStop => e
  render text: e.message unless @performed_render
end

#save_table_positionObject



50
51
52
53
54
# File 'app/controllers/admin/pages_controller.rb', line 50

def save_table_position
  new_position = params[:new_position]
  Page.save_order(new_position)
  head :ok
end