Files
mozo-backend/app/controllers/suppliers/sections_controller.rb
T
2012-08-28 20:08:13 +02:00

88 lines
2.3 KiB
Ruby

module Suppliers
class SectionsController < Suppliers::ApplicationController
# GET /sections
# GET /sections.json
def index
@sections = current_supplier.sections
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sections }
end
end
# GET /sections/1
# GET /sections/1.json
def show
@section = Section.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @section }
end
end
# GET /sections/new
# GET /sections/new.json
def new
@section = Section.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @section }
end
end
# GET /sections/1/edit
def edit
@section = Section.find(params[:id])
end
# POST /sections
# POST /sections.json
def create
@section = Section.new(params[:section])
@section.supplier = current_supplier
respond_to do |format|
if @section.save
format.html { redirect_to [:suppliers, @section], notice: t('action.create.successfull', model: Section.model_name.human) }
format.json { render json: @section, status: :created, location: @section }
else
format.html { render action: "new" }
format.json { render json: @section.errors, status: :unprocessable_entity }
end
end
end
# PUT /sections/1
# PUT /sections/1.json
def update
@section = Section.find(params[:id])
respond_to do |format|
if @section.update_attributes(params[:section])
format.html { redirect_to [:suppliers, @section], notice: t('action.update.successfull', model: Section.model_name.human) }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @section.errors, status: :unprocessable_entity }
end
end
end
# DELETE /sections/1
# DELETE /sections/1.json
def destroy
@section = Section.find(params[:id])
@section.destroy
respond_to do |format|
format.html { redirect_to suppliers_sections_url, notice: t('action.destroy.successfull', model: Section.model_name.human) }
format.json { head :no_content }
end
end
end
end