Sha256: 5d0b1be6e44db11cc3730651102b3b91473d1b7bf0ae2e1979af85052821879d
Contents?: true
Size: 1.39 KB
Versions: 46
Compression:
Stored size: 1.39 KB
Contents
module Pageflow class PagesController < Pageflow::ApplicationController respond_to :json before_filter :authenticate_user! def create chapter = Chapter.find(params[:chapter_id]) page = chapter.pages.build(page_params) authorize!(:create, page) verify_edit_lock!(page.chapter.entry) page.save respond_with(page) end def update page = Page.find(params[:id]) authorize!(:update, page) verify_edit_lock!(page.chapter.entry) page.update_attributes(page_params) respond_with(page) end def order chapter = Chapter.find(params[:chapter_id]) entry = DraftEntry.new(chapter.entry) authorize!(:edit_outline, entry.to_model) verify_edit_lock!(chapter.entry) params.require(:ids).each_with_index do |id, index| entry.pages.update(id, :chapter_id => chapter.id, :position => index) end head :no_content end def destroy page = Page.find(params[:id]) authorize!(:destroy, page) verify_edit_lock!(page.chapter.entry) page.chapter.entry.snapshot(:creator => current_user) page.destroy respond_with(page) end private def page_params configuration = params.require(:page)[:configuration].try(:permit!) params.require(:page).permit(:template, :position, :title).merge(:configuration => configuration) end end end
Version data entries
46 entries across 46 versions & 1 rubygems