Class: CrazyTrain::ResourcesController
Instance Method Summary
collapse
#jwt_payload, #jwt_token, #setup_role, #switch_role, #teardown_role, #verify_token
Instance Method Details
#create ⇒ Object
16
17
18
19
20
|
# File 'app/controllers/crazy_train/resources_controller.rb', line 16
def create
klass.create!(resource_params.to_h)
head :created
end
|
#destroy ⇒ Object
29
30
31
32
33
34
|
# File 'app/controllers/crazy_train/resources_controller.rb', line 29
def destroy
resource = klass.find(params[:id])
resource.destroy!
head :no_content
end
|
#index ⇒ Object
3
4
5
6
7
8
9
|
# File 'app/controllers/crazy_train/resources_controller.rb', line 3
def index
query_builder = CrazyTrain::QueryBuilder.new(klass, params)
query_builder.parse!
records = query_builder.query
render json: records
end
|
#show ⇒ Object
11
12
13
14
|
# File 'app/controllers/crazy_train/resources_controller.rb', line 11
def show
resource = klass.find(params[:id])
render json: resource
end
|
#update ⇒ Object
22
23
24
25
26
27
|
# File 'app/controllers/crazy_train/resources_controller.rb', line 22
def update
resource = klass.find(params[:id])
resource.update!(resource_params.to_h)
head :no_content
end
|