personal-book/app/controllers/admin/book_author_types_controlle...

44 lines
1.1 KiB
Ruby

class Admin::BookAuthorTypesController < OrbitMemberController
before_action :allow_admin_only
def new
@author_type = BookAuthorType.new
@url = admin_book_author_types_path(@author_type)
render :layout=>false
end
def create
@author_type = BookAuthorType.new(author_type_params)
@author_type.save
@author_types = BookAuthorType.all
render :partial=>'list', :layout=>false
end
def edit
@author_type = BookAuthorType.find(params[:id])
@url = admin_book_author_type_path(@author_type)
render :layout=>false
end
def update
@author_type = BookAuthorType.find(params[:id])
@author_type.update_attributes(author_type_params)
@author_type.save
@author_types = BookAuthorType.all
render :partial=>'list', :layout=>false
end
def destroy
author_type = BookAuthorType.find(params[:id])
author_type.destroy
@author_types = BookAuthorType.all
render :partial=>'list', :layout=>false
end
private
def author_type_params
params.require(:book_author_type).permit! rescue nil
end
end