I have problems with my hero server. No problem occurs locally:
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'
My 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
I just added the author name with
rails g migration add_authorname_to_chapter authorname:string
What am I missing?
Edit by adding schema information: ActiveRecord :: Schema.define (version: 20140723154333) do
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
source
share