Sha256: 3d0a8c44a8f74220a50fd138c33ca21c588726a51b9b125898470732ec47c01b

Contents?: true

Size: 829 Bytes

Versions: 3

Compression:

Stored size: 829 Bytes

Contents

require_dependency "cardboard/application_controller"

module Cardboard
  class PagesController < ApplicationController
    before_filter :check_ability

    def edit
      @page = Cardboard::Page.find(params[:id])
    end

    def update
      @page = Cardboard::Page.find(params[:id])

      if @page.update_attributes(strong_params[:page])
        flash[:success] = "Your page was updated successfully"
        redirect_to edit_page_path(@page)
      else
        render :edit
      end
    end

    def sort
      Page.find(params[:id]).update_attribute(:position_position, params[:index])
      render nothing: true
    end

  private
    def check_ability
      unless cardboard_user_can_manage?(:pages)
        render :text => "You are not authorized to edit pages.", :status => :unauthorized 
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cardboard_cms-0.1.8 app/controllers/cardboard/pages_controller.rb
cardboard_cms-0.1.6 app/controllers/cardboard/pages_controller.rb
cardboard_cms-0.1.4 app/controllers/cardboard/pages_controller.rb