103 lines
2.4 KiB
Ruby
103 lines
2.4 KiB
Ruby
class TablesController < ApplicationController
|
|
before_filter :set_relation_options, only: [:new, :edit, :create, :update]
|
|
# GET /tables
|
|
# GET /tables.json
|
|
def index
|
|
@tables = Table.all
|
|
|
|
respond_to do |format|
|
|
format.html # index.html.erb
|
|
format.json { render json: @tables }
|
|
end
|
|
end
|
|
|
|
# GET /tables/1
|
|
# GET /tables/1.json
|
|
def show
|
|
@table = Table.find(params[:id])
|
|
|
|
respond_to do |format|
|
|
format.html # show.html.erb
|
|
format.json { render json: @table }
|
|
end
|
|
end
|
|
|
|
# GET /tables/new
|
|
# GET /tables/new.json
|
|
def new
|
|
@table = Table.new
|
|
|
|
respond_to do |format|
|
|
format.html # new.html.erb
|
|
format.json { render json: @table }
|
|
end
|
|
end
|
|
|
|
# GET /tables/1/edit
|
|
def edit
|
|
@table = Table.find(params[:id])
|
|
end
|
|
|
|
# POST /tables
|
|
# POST /tables.json
|
|
def create
|
|
@table = Table.new(params[:table])
|
|
|
|
respond_to do |format|
|
|
if @table.save
|
|
format.html { redirect_to @table, notice: t('action.create.successfull', model: Table.model_name.human) }
|
|
format.json { render json: @table, status: :created, location: @table }
|
|
else
|
|
format.html { render action: "new" }
|
|
format.json { render json: @table.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# PUT /tables/1
|
|
# PUT /tables/1.json
|
|
def update
|
|
@table = Table.find(params[:id])
|
|
|
|
respond_to do |format|
|
|
if @table.update_attributes(params[:table])
|
|
format.html { redirect_to @table, notice: t('action.update.successfull', model: Table.model_name.human) }
|
|
format.json { head :no_content }
|
|
else
|
|
format.html { render action: "edit" }
|
|
format.json { render json: @table.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# DELETE /tables/1
|
|
# DELETE /tables/1.json
|
|
def destroy
|
|
@table = Table.find(params[:id])
|
|
@table.destroy
|
|
|
|
respond_to do |format|
|
|
format.html { redirect_to tables_url, notice: t('action.destroy.successfull', model: Table.model_name.human) }
|
|
format.json { head :no_content }
|
|
end
|
|
end
|
|
|
|
# GET /tables/qrcode
|
|
# GET /tables/qrcode.png
|
|
# GET /tables/qrcode.svg
|
|
def qrcode
|
|
respond_to do |format|
|
|
format.html
|
|
format.svg { render :qrcode => request.url, :level => :l, :unit => 10 }
|
|
format.png { render qrcode: request.url }
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def set_relation_options
|
|
@suppliers = Supplier.all
|
|
@lists = List.all
|
|
end
|
|
end
|