Qwaiter in the green 💚

This commit is contained in:
2013-12-22 15:20:14 +01:00
parent 76c2d4ddbc
commit 69132b0c07
20 changed files with 150 additions and 935 deletions
+20 -16
View File
@@ -6,46 +6,46 @@ module Admin
# GET /sections.json
def index
@sections = Section.all
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 = Section.new(section_params)
@section.supplier_id = params[:section][:supplier_id]
respond_to do |format|
if @section.save
format.html { redirect_to [:admin, @section], notice: t('action.create.successfull', model: Section.model_name.human) }
@@ -56,14 +56,14 @@ module Admin
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])
if @section.update_attributes(section_params)
format.html { redirect_to [:admin, @section], notice: t('action.update.successfull', model: Section.model_name.human) }
format.json { head :no_content }
else
@@ -72,23 +72,27 @@ module Admin
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 admin_sections_path, notice: t('action.destroy.successfull', model: Section.model_name.human) }
format.json { head :no_content }
end
end
private
def set_relation_options
@suppliers = Supplier.all
end
def section_params
params.require(:section).permit!
end
end
end