現在、rubyを用いた本棚アプリの書籍画面にrukaminariを用いてページネーションを実装しようとしているのですが、以下のようなエラーコードが吐き出され、成功しません。
なお、
app/controllers/book_controller.rbのようになっております。
class BooksController < ApplicationController
before_action :set_book, only: [:show, :edit, :update, :destroy]
def index
@books = Book.page(params[:page]).per(10)
end
GET /books
GET /books.json
def index
@books = Book.all
end
GET /books/1
GET /books/1.json
def show
end
GET /books/new
def new
@book = Book.new
end
GET /books/1/edit
def edit
end
POST /books
POST /books.json
def create
@book = Book.new(book_params)
respond_to do |format| if @book.save format.html { redirect_to @book, notice: 'Book was successfully created.' } format.json { render :show, status: :created, location: @book } else format.html { render :new } format.json { render json: @book.errors, status: :unprocessable_entity } end end
end
PATCH/PUT /books/1
PATCH/PUT /books/1.json
def update
respond_to do |format|
if @book.update(book_params)
format.html { redirect_to @book, notice: 'Book was successfully updated.' }
format.json { render :show, status: :ok, location: @book }
else
format.html { render :edit }
format.json { render json: @book.errors, status: :unprocessable_entity }
end
end
end
DELETE /books/1
DELETE /books/1.json
def destroy
@book.destroy
respond_to do |format|
format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_book
@book = Book.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through. def book_params params.require(:book).permit(:title, :author) end
end
また、app/views/books/index.html.erbは下記のようになっております。
class BooksController < ApplicationController
before_action :set_book, only: [:show, :edit, :update, :destroy]
def index
@books = Book.page(params[:page]).per(10)
end
GET /books
GET /books.json
def index
@books = Book.all
end
GET /books/1
GET /books/1.json
def show
end
GET /books/new
def new
@book = Book.new
end
GET /books/1/edit
def edit
end
POST /books
POST /books.json
def create
@book = Book.new(book_params)
respond_to do |format| if @book.save format.html { redirect_to @book, notice: 'Book was successfully created.' } format.json { render :show, status: :created, location: @book } else format.html { render :new } format.json { render json: @book.errors, status: :unprocessable_entity } end end
end
PATCH/PUT /books/1
PATCH/PUT /books/1.json
def update
respond_to do |format|
if @book.update(book_params)
format.html { redirect_to @book, notice: 'Book was successfully updated.' }
format.json { render :show, status: :ok, location: @book }
else
format.html { render :edit }
format.json { render json: @book.errors, status: :unprocessable_entity }
end
end
end
DELETE /books/1
DELETE /books/1.json
def destroy
@book.destroy
respond_to do |format|
format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_book
@book = Book.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through. def book_params params.require(:book).permit(:title, :author) end
end
自身でも調べては見たものの、エラーを解決することはできず、多くの場合、別のエラーに変わるだけでした。
そのため、皆様にどこが問題のかを指摘していただく、質問いたしました。
何か情報に不足があれば、お伝え下さい。よろしくお願いいたします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。