Class: RestApiGenerator::ChildResourceController
Constant Summary
Constants included
from Orderable
Orderable::SORT_ORDER
Instance Method Summary
collapse
#index_serializer, #serializer
Methods included from Orderable
#ordering_params
Instance Method Details
#create ⇒ Object
27
28
29
30
|
# File 'app/controllers/rest_api_generator/child_resource_controller.rb', line 27
def create
@resource = resources.create!(resource_created_params)
render json: serializer(@resource), status: :created
end
|
#destroy ⇒ Object
37
38
39
|
# File 'app/controllers/rest_api_generator/child_resource_controller.rb', line 37
def destroy
@resource.destroy!
end
|
#index ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# File 'app/controllers/rest_api_generator/child_resource_controller.rb', line 12
def index
set_all_resources
@resources = @resources.filter_resource(params_for_filter) if resource_class.include?(Filterable)
@resources = @resources.order(ordering_params(params[:sort])) if params[:sort]
if
@pagy, @resources = pagy(@resources)
(@pagy)
end
render json: index_serializer(@resources), status: :ok
end
|
#show ⇒ Object
23
24
25
|
# File 'app/controllers/rest_api_generator/child_resource_controller.rb', line 23
def show
render json: serializer(@resource), status: :ok
end
|
#update ⇒ Object
32
33
34
35
|
# File 'app/controllers/rest_api_generator/child_resource_controller.rb', line 32
def update
@resource.update!(resource_updated_params)
render json: serializer(@resource), status: :ok
end
|