gpt4 book ai didi

ruby-on-rails - 1 个错误禁止保存此书

转载 作者:数据小太阳 更新时间:2023-10-29 07:29:46 25 4
gpt4 key购买 nike

<分区>

我在创作新书时遇到了问题。用户已登录,但仍然显示:

1 个错误禁止保存这本书

  • 用户必须存在

当我编辑我的书时它工作正常但是当我尝试创建新书时它显示.error/

这是图书 Controller :

    class BooksController < ApplicationController
before_action :find_book, only:[:show, :edit, :update, :destroy, :upvote]
before_action :authenticate_user!
def index
@books = Book.all.order('created_at DESC')
end


def show
end

def edit
end

def update
if @book.update(book_params)
redirect_to @book
else
render 'edit'
end
end
def destroy
@book.destroy
redirect_to root_path, notice: "successfully deleted"
end

def new
@book =Book.new

end

def create
@book =Book.new(book_params)
if @book.save
redirect_to @book
else
render 'new'
end
end

private

def find_book
@book=Book.find(params[:id])
end

def book_params
params.require(:book).permit(:title, :description, :image)
end
end

我的 books.rb 是:

 class Book < ApplicationRecord
#Paperclip.options[:command_path] = 'C:\Program Files\ImageMagick-7.0.5-Q16'
has_attached_file :image, styles: { }
do_not_validate_attachment_file_type :image
#validates_attachment_content_type :image, content_type: /\Aimage\/.*\z/
belongs_to :user
end

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com