77 lines
975 B
Ruby
77 lines
975 B
Ruby
# -*- encoding : utf-8 -*-
|
|
|
|
class Admin::PTanksController < ApplicationController
|
|
layout "admin"
|
|
before_filter :auth_admin
|
|
|
|
before_filter :admin_space
|
|
|
|
def admin_space
|
|
@admin_space = "stocks"
|
|
end
|
|
|
|
def index
|
|
@p_tanks = PTank.order(:name).all
|
|
|
|
|
|
end
|
|
|
|
def show
|
|
@p_tank = PTank.find(params[:id])
|
|
|
|
end
|
|
|
|
def new
|
|
|
|
|
|
@p_tank = PTank.new
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
|
|
@p_tank = PTank.find(params[:id])
|
|
end
|
|
|
|
def create
|
|
@p_tank = PTank.new(params.require(:p_tank).permit!)
|
|
|
|
|
|
if @p_tank.save
|
|
@p_tanks = PTank.order(:name).all
|
|
|
|
else
|
|
render action: "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
@p_tank = PTank.find(params[:id])
|
|
|
|
|
|
if @p_tank.update_attributes(params.require(:p_tank).permit!)
|
|
|
|
@p_tanks = PTank.order(:name).all
|
|
else
|
|
render action: "edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
@p_tank = PTank.find(params[:id])
|
|
@p_tank.destroy
|
|
|
|
|
|
end
|
|
end
|