Sha256: 4df3f0bc133df38b19e22ed1f807ddeeddb679c178a06a9907610d7c9d4cdb76
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
require_dependency "bouquet/gate/application_controller" module Bouquet class Gate::MaterialsController < ApplicationController before_action :set_material, only: [:show, :update, :destroy] # GET /materials def index @materials = Bouquet::Material.all render json: @materials end # GET /materials/1 def show render json: @material end # POST /materials def create @material = Bouquet::Material.new(material_params) if @material.save render json: @material, status: :created, location: @material else render json: @material.errors, status: :unprocessable_entity end end # PATCH/PUT /materials/1 def update if @material.update(material_params) render json: @material else render json: @material.errors, status: :unprocessable_entity end end # DELETE /materials/1 def destroy @material.destroy end private # Use callbacks to share common setup or constraints between actions. def set_material @material = Bouquet::Material.find(params[:id]) end # Only allow a trusted parameter "white list" through. def material_params params.require(:material).permit(:name) end end end
Version data entries
3 entries across 3 versions & 1 rubygems