私のアプリはローカルで完璧に動作しますが、Heroku
に問題が発生しました。Heroku Rails NoMethodError
Herokuのログ
2016-07-05T16:29:58.946783+00:00 app[web.1]: Started GET "/posts/new" for 110.30.34.50 at 2016-07-05 16:29:58 +0000
2016-07-05T16:29:58.955329+00:00 app[web.1]: Rendered posts/_form.html.erb (2.4ms)
2016-07-05T16:29:58.955545+00:00 app[web.1]: Rendered posts/new.html.erb within layouts/application (3.4ms)
2016-07-05T16:30:05.508001+00:00 app[web.1]: Started POST "/posts" for 110.30.34.50 at 2016-07-05 16:30:05 +0000
2016-07-05T16:30:05.510085+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"0DzbuSXUyjZ4FRYietP3QSdmjfHymWyu7INcGpm79b2PgR+3LD99TS6gkYCF0FCLLHso9U7YqMh1tzr48ch8Jw==", "post"=>{"title"=>"123", "content"=>"123"}, "commit"=>"Create Post"}
2016-07-05T16:30:05.515017+00:00 app[web.1]: app/controllers/posts_controller.rb:32:in `create'
2016-07-05T16:30:05.512757+00:00 app[web.1]: Author Load (1.2ms) SELECT "authors".* FROM "authors" WHERE "authors"."id" = $1 ORDER BY "authors"."id" ASC LIMIT 1 [["id", 1]]
2016-07-05T16:30:05.513954+00:00 app[web.1]: Completed 500 Internal Server Error in 4ms (ActiveRecord: 1.2ms)
2016-07-05T16:30:05.515003+00:00 app[web.1]:
2016-07-05T16:30:05.515016+00:00 app[web.1]: NoMethodError (undefined method `author_id=' for #<Post:0x007fcf1cc579f0>):
2016-07-05T16:30:05.509973+00:00 app[web.1]: Processing by PostsController#create as HTML
2016-07-05T16:30:05.515018+00:00 app[web.1]:
2016-07-05T16:30:05.515019+00:00 app[web.1]:
私はpost
を作成したいと= current_author.id
author_id
を与えました。
#in post controller
def create
@post = Post.new(post_params)
@post.author_id = current_author.id if current_author
...
私は、私はあなたが最近投稿テーブルに著者の参照を追加したと思いますGithub
ありがとう、私はこの簡単なステップを忘れました。 –