Sha256: 6bcf79ecb220ca905f7294bb776d4e35883f951f1d6e53cfc46937ede9f8fa62
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
module TypeStation module Admin class PagesController < ::TypeStation::AdminController def index @pages = TypeStation::Page.in(type: [:draft, :published]) @pages = @pages.where(title: /#{params[:title]}/i) if params[:title] @pages = @pages.where(path: /#{params[:path]}/i) if params[:path] render json: { status: :success, pages: @pages }, status: :ok end def create @page = TypeStation::Page.new(title: params[:title]) if params[:parent_id] parent_page = TypeStation::Page.find(params[:parent_id]) @page.parent = parent_page end if @page.update_contents(contents) render json: { status: :success, url: @page.path }, status: :ok else render json: @page.errors, status: :unprocessable_entity end end def update @page = TypeStation::Page.find(params[:id]) if params[:direction] @page.move_page params[:direction] end if @page.update_contents(contents) render json: { status: :success }, status: :ok else render json: @page.errors, status: :unprocessable_entity end end def destroy @page = TypeStation::Page.find(params[:id]) if @page.delete render json: { status: :success }, status: :ok else render json: @page.errors, status: :unprocessable_entity end end private def contents [params[:contents]].compact.flatten end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
type_station-0.1.3 | app/controllers/type_station/admin/pages_controller.rb |
type_station-0.1.1 | app/controllers/type_station/admin/pages_controller.rb |