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

51 lines
1.0 KiB
Ruby

class Admin::BookAuthorTypesController < ApplicationController
before_action :set_book_author_type, only: [:edit, :update, :destroy]
def initialize
super
@app_type = 'book_author_type'
end
def new
@book_author_type = BookAuthorType.new
end
def edit
end
def create
@book_author_type = BookAuthorType.new(book_author_type_attributes)
respond_to do |format|
if @book_author_type.save
format.js { render 'create_book_setting' }
end
end
end
def update
respond_to do |format|
if @book_author_type.update_attributes(book_author_type_attributes)
format.js { render 'update_book_setting' }
end
end
end
def destroy
@book_author_type.destroy
respond_to do |format|
format.js { render 'delete_book_setting' }
end
end
private
def set_book_author_type
@book_author_type = BookAuthorType.find(params[:id])
end
def book_author_type_attributes
params.require(:book_author_type).permit! rescue nil
end
end