43 lines
971 B
Ruby
43 lines
971 B
Ruby
class Admin::BookTypesController < OrbitMemberController
|
|
before_action :allow_admin_only
|
|
|
|
def new
|
|
@book_type = BookType.new
|
|
@url = admin_book_types_path(@book_type)
|
|
render :layout=>false
|
|
end
|
|
|
|
def create
|
|
@book_type = BookType.new(book_type_params)
|
|
@book_type.save
|
|
@book_types = BookType.all
|
|
render :partial=>'list', :layout=>false
|
|
end
|
|
|
|
def edit
|
|
@book_type = BookType.find(params[:id])
|
|
@url = admin_book_type_path(@book_type)
|
|
render :layout=>false
|
|
end
|
|
|
|
def update
|
|
@book_type = BookType.find(params[:id])
|
|
@book_type.update_attributes(book_type_params)
|
|
@book_type.save
|
|
@book_types = BookType.all
|
|
render :partial=>'list', :layout=>false
|
|
end
|
|
|
|
def destroy
|
|
book_type = BookType.find(params[:id])
|
|
book_type.destroy
|
|
@book_types = BookType.all
|
|
render :partial=>'list', :layout=>false
|
|
end
|
|
|
|
private
|
|
|
|
def book_type_params
|
|
params.require(:book_type).permit! rescue nil
|
|
end
|
|
end |