75 lines
1.9 KiB
Ruby
75 lines
1.9 KiB
Ruby
class GemCraftsController < ApplicationController
|
|
before_action :set_gem_craft, only: [:show, :edit, :update, :destroy]
|
|
|
|
# GET /gem_crafts
|
|
# GET /gem_crafts.json
|
|
def index
|
|
@gem_crafts = GemCraft.all
|
|
end
|
|
|
|
# GET /gem_crafts/1
|
|
# GET /gem_crafts/1.json
|
|
def show
|
|
end
|
|
|
|
# GET /gem_crafts/new
|
|
def new
|
|
@gem_craft = GemCraft.new
|
|
end
|
|
|
|
# GET /gem_crafts/1/edit
|
|
def edit
|
|
end
|
|
|
|
# POST /gem_crafts
|
|
# POST /gem_crafts.json
|
|
def create
|
|
@gem_craft = GemCraft.new(gem_craft_params)
|
|
|
|
respond_to do |format|
|
|
if @gem_craft.save
|
|
format.html { redirect_to @gem_craft, notice: 'Gem craft was successfully created.' }
|
|
format.json { render action: 'show', status: :created, location: @gem_craft }
|
|
else
|
|
format.html { render action: 'new' }
|
|
format.json { render json: @gem_craft.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# PATCH/PUT /gem_crafts/1
|
|
# PATCH/PUT /gem_crafts/1.json
|
|
def update
|
|
respond_to do |format|
|
|
if @gem_craft.update(gem_craft_params)
|
|
format.html { redirect_to @gem_craft, notice: 'Gem craft was successfully updated.' }
|
|
format.json { head :no_content }
|
|
else
|
|
format.html { render action: 'edit' }
|
|
format.json { render json: @gem_craft.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# DELETE /gem_crafts/1
|
|
# DELETE /gem_crafts/1.json
|
|
def destroy
|
|
@gem_craft.destroy
|
|
respond_to do |format|
|
|
format.html { redirect_to gem_crafts_url }
|
|
format.json { head :no_content }
|
|
end
|
|
end
|
|
|
|
private
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
def set_gem_craft
|
|
@gem_craft = GemCraft.find(params[:id])
|
|
end
|
|
|
|
# Never trust parameters from the scary internet, only allow the white list through.
|
|
def gem_craft_params
|
|
params.require(:gem_craft).permit(:name, :price, :books_type, :books_qnt, :previous_id, :previous_qnt)
|
|
end
|
|
end
|