66 lines
1.1 KiB
Ruby
66 lines
1.1 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
|
|
class Admin::<%= controller_class_name %>Controller < ApplicationController
|
|
layout "admin"
|
|
before_action :auth_admin
|
|
|
|
before_action :admin_space
|
|
|
|
def admin_space
|
|
@admin_space = "default"
|
|
end
|
|
|
|
def index
|
|
@<%= plural_name %> = <%= class_name %>.order(:name).all
|
|
|
|
end
|
|
|
|
def show
|
|
@<%= singular_name %> = <%= class_name %>.find(params[:id])
|
|
|
|
end
|
|
|
|
def new
|
|
@<%= singular_name %> = <%= class_name %>.new
|
|
|
|
end
|
|
|
|
def edit
|
|
@<%= singular_name %> = <%= class_name %>.find(params[:id])
|
|
|
|
end
|
|
|
|
def create
|
|
@<%= singular_name %> = <%= class_name %>.new(params.require(:<%= singular_name %>).permit!)
|
|
|
|
if @<%= singular_name %>.save
|
|
|
|
else
|
|
render action: "new"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def update
|
|
@<%= singular_name %> = <%= class_name %>.find(params[:id])
|
|
|
|
|
|
if @<%= singular_name %>.update_attributes(params.require(:<%= singular_name %>).permit!)
|
|
|
|
else
|
|
render action: "edit"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
def destroy
|
|
@<%= singular_name %> = <%= class_name %>.find(params[:id])
|
|
@<%= singular_name %>.destroy
|
|
|
|
end
|
|
end
|