ActiveRecord :: UnknownAttributeError(未知属性:authorname):

yar*_*ism 4 ruby ruby-on-rails

我在我的heroku服务器上遇到了一些麻烦.没有在本地出现此问题:

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'
Run Code Online (Sandbox Code Playgroud)

我的控制器:

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
Run Code Online (Sandbox Code Playgroud)

我刚刚添加了authorname

rails g migration add_authorname_to_chapter authorname:string
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

编辑,添加架构信息:ActiveRecord :: Schema.define(版本: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
Run Code Online (Sandbox Code Playgroud)

Pau*_*yng 5

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