Sha256: d0a0a13134db2ba752bc3ebc868edb901a796b9ce6fa0dbc7ab1933f6c68371e
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 KB
Contents
module Refinery module Api module V1 class PagesController < Refinery::Api::BaseController def index if params[:ids] @pages = Refinery::Page. includes(:translations, :children). accessible_by(current_ability, :read). where(id: params[:ids].split(',')) else @pages = Refinery::Page. includes(:translations, :children). accessible_by(current_ability, :read). # ransack(params[:q]).result order(:lft) end respond_with(@pages) end def show @page = page respond_with(@page) end def new end def create authorize! :create, Page @page = Refinery::Page.new(page_params) if @page.save respond_with(@page, status: 201, default_template: :show) else invalid_resource!(@page) end end def update authorize! :update, page if page.update_attributes(page_params) respond_with(page, status: 200, default_template: :show) else invalid_resource!(page) end end def destroy authorize! :destroy, page page.destroy respond_with(page, status: 204) end private def page @page ||= Refinery::Page. includes(:translations, :parts). accessible_by(current_ability, :read). find(params[:id]) end def page_params if params[:page] && !params[:page].empty? params.require(:page).permit(permitted_page_attributes) else {} end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
refinerycms-api-1.0.0.beta | app/controllers/refinery/api/v1/pages_controller.rb |