Class: Api::PageTypesController

Inherits:
ApiController
  • Object
show all
Defined in:
app/controllers/api/page_types_controller.rb

Instance Method Summary collapse

Methods inherited from ApiController

#current_user

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/api/page_types_controller.rb', line 11

def create
    render nothing: true, status: 400 unless params[:page_type]
    page_type = BillyCms::PageType.new page_type_params
    if page_type.save
        render json: {
            success: true,
            page_type: page_type
        }
    else
        render json: {
            success: false,
            error: page_type.error_messages,
        }, status: 500
    end
end

#indexObject



3
4
5
# File 'app/controllers/api/page_types_controller.rb', line 3

def index
    render json: BillyCms::PageType.all.includes(:additional_attributes)
end

#showObject



7
8
9
# File 'app/controllers/api/page_types_controller.rb', line 7

def show
    render json: BillyCms::PageType.find(params[:id])
end