2015-01-09 07:38:49 +00:00
|
|
|
class Admin::BookTypesController < OrbitMemberController
|
|
|
|
before_action :allow_admin_only
|
|
|
|
|
2014-07-03 07:48:28 +00:00
|
|
|
def new
|
2015-01-09 07:38:49 +00:00
|
|
|
@book_type = BookType.new
|
|
|
|
@url = admin_book_types_path(@book_type)
|
|
|
|
render :layout=>false
|
2014-07-03 07:48:28 +00:00
|
|
|
end
|
|
|
|
|
2015-01-09 07:38:49 +00:00
|
|
|
def create
|
|
|
|
@book_type = BookType.new(book_type_params)
|
|
|
|
@book_type.save
|
|
|
|
@book_types = BookType.all
|
|
|
|
render :partial=>'list', :layout=>false
|
2014-07-03 07:48:28 +00:00
|
|
|
end
|
|
|
|
|
2015-01-09 07:38:49 +00:00
|
|
|
def edit
|
|
|
|
@book_type = BookType.find(params[:id])
|
|
|
|
@url = admin_book_type_path(@book_type)
|
|
|
|
render :layout=>false
|
2014-07-03 07:48:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2015-01-09 07:38:49 +00:00
|
|
|
@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
|
2014-07-03 07:48:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2015-01-09 07:38:49 +00:00
|
|
|
book_type = BookType.find(params[:id])
|
|
|
|
book_type.destroy
|
|
|
|
@book_types = BookType.all
|
|
|
|
render :partial=>'list', :layout=>false
|
2014-07-03 07:48:28 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2015-01-09 07:38:49 +00:00
|
|
|
def book_type_params
|
2014-07-03 07:48:28 +00:00
|
|
|
params.require(:book_type).permit! rescue nil
|
|
|
|
end
|
2015-01-09 07:38:49 +00:00
|
|
|
end
|