gpt4 book ai didi

ruby-on-rails - ActiveRecord::UnknownAttributeError(未知属性:作者姓名):

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

我的 heroku-server 出现了一些问题。在本地没有遇到这个问题:

2014-07-23T16:59:23.249055+00:00 app[web.1]: ActiveRecord::UnknownAttributeError (unknown attribute: authorname):
2014-07-23T16:59:23.249058+00:00 app[web.1]: app/controllers/chapters_controller.rb:5:in `create'

我的 Controller :

class ChaptersController < ApplicationController

def create
@story = Story.find(params[:story_id])
@chapter = @story.chapters.create(chapter_params)
redirect_to story_path(@story)
end

def destroy
@story = Story.find(params[:story_id])
@chapter = @story.chapters.find(params[:id])
@chapter.destroy
redirect_to story_path(@story)
end

def upvote
@chapter = Chapter.find(params[:id])
@chapter.votes.create
redirect_to(:back)
end

private
def chapter_params
params.require(:chapter).permit(:round, :author, :authorname, :body)
end
end

我刚刚添加了作者姓名

rails g migration add_authorname_to_chapter authorname:string

我错过了什么?

编辑,添加模式信息:ActiveRecord::Schema.define(version: 20140723154333) 做

  create_table "chapters", force: true do |t|
t.string "round"
t.string "author"
t.text "body"
t.integer "story_id"
t.datetime "created_at"
t.datetime "updated_at"
t.string "authorname"
end

最佳答案

迁移后重新启动服务器将刷新架构缓存。

关于ruby-on-rails - ActiveRecord::UnknownAttributeError(未知属性:作者姓名):,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24916843/

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