I am having a some trouble on my heroku-server. Not getting this problem 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 have just added authorname with
rails g migration add_authorname_to_chapter authorname:string
What am I missing?
Edit, adding schema info: 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
Restarting your server after migration will refresh the schema cache.
For the case that a restart doesn't work I was able to resolve this issue by also dumping the schema:
heroku run rake db:schema:dump
heroku restart
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With