summaryrefslogtreecommitdiff
path: root/app/controllers/pages_controller.rb
blob: 4b3b541f759eb067ef0fe2bc2b7bf0976d8ae4ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
class PagesController < ApplicationController
    
  def preview
    @page = Page.find(params[:id])
    
    if @page
      template = @page.valid_template
      render(
        :file => template,
        :layout => "application"
      )
    end
    
  end
  
  
  def sort_images
    page = Page.find(params[:id])
    
    page.related_assets.destroy_all
    
    params[:images].each_with_index do |id, index|
      asset = Asset.find(id)
      page.related_assets.create(:asset_id => asset.id, :position => index+1)
    end
    
    render :nothing => true, :status => 200
  end
end