質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

1回答

967閲覧

heroku デプロイ後 HTML表示されない

munequn

総合スコア17

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

1クリップ

投稿2019/10/02 14:51

編集2019/10/03 12:08

ローカル環境で表示されるもの
イメージ説明

herokuで表示されるもの
イメージ説明

●前提
ローカルでは問題なく動作しています。
DBテーブル、カラムも存在を確認しました。
●実現したいこと
ローカルと同じように表示したいです。
●試したこと
heroku logs -tでログを確認しましたが解決策が見つからず、、、errorの対象

Completed 500 Internal Server Error in 10ms (ActiveRecord: 1.7ms | Allocations: 1035)
ActionView::Template::Error (PG::UndefinedColumn: ERROR: column posts.user_id does not exist 2019-10-01T10:02:22.350382+00:00 app[web.1]: LINE 1: SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = $1

表示したいソースコード

<div class="main user-show"> <div class="container"> <div class="user"> <img src="<%= "/user_images/#{@user.image_name}" %>"> <h2><%= @user.name %></h2> <!-- <p><%= @user.email %></p> --> <% if @user.id == @current_user.id %> <%= link_to("編集", "/users/#{@user.id}/edit") %> <% end %> </div> <ul class="user-tabs"> <li class="active"><%= link_to("投稿", "/users/#{@user.id}") %></li> <li><%= link_to("いいね!", "/users/#{@user.id}/likes") %></li> </ul> <% @user.posts.each do |post| %> <div class="posts-index-item"> <div class="post-left"> <img src="<%= "/user_images/#{post.user.image_name}" %>"> </div> <div class="post-right"> <div class="post-user-name"> <%= link_to(post.user.name, "/users/#{post.user.id}") %> </div> <%= link_to(post.content, "/posts/#{post.id}") %> </div> </div> <% end %> </div> </div>

WARNING

remote: ###### WARNING: remote: remote: You set your `config.assets.compile = true` in production. remote: This can negatively impact the performance of your application. remote: remote: For more information can be found in this article: remote: https://devcenter.heroku.com/articles/rails-asset-pipeline#compile-set-to-true-in-production remote: remote: remote: ###### WARNING: remote: remote: You set your `config.active_storage.service` to :local in production. remote: If you are uploading files to this app, they will not persist after the app remote: is restarted, on one-off dynos, or if the app has multiple dynos. remote: Heroku applications have an ephemeral file system. To remote: persist uploaded files, please use a service such as S3 and update your Rails remote: configuration. remote: remote: For more information can be found in this article: remote: https://devcenter.heroku.com/articles/active-storage-on-heroku remote: remote: remote: ###### WARNING: remote: remote: We detected that some binary dependencies required to remote: use all the preview features of Active Storage are not remote: present on this system. remote: remote: For more information please see: remote: https://devcenter.heroku.com/articles/active-storage-on-heroku remote: remote: remote: ###### WARNING: remote: remote: No Procfile detected, using the default web server. remote: We recommend explicitly declaring how to boot your server process via a Procfile. remote: https://devcenter.heroku.com/articles/ruby-default-web-server remote:

rails 6.0.0
dbローカル sqlite3
db本番 pg

丸投げになってしまうかもしれませんが何卒よろしくお願い致します。
追記情報あれば言ってください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

DBのマイグレートはお済みでしょうか。

heroku run rake db:migrate

投稿2019/10/02 14:54

kokemomo.sour

総合スコア330

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

munequn

2019/10/02 15:08

はい、実行済みです!
munequn

2019/10/02 15:10

PG::DuplicateTable: ERROR: relation "likes" already existsと表示を発見しました。
kokemomo.sour

2019/10/02 15:12

ちなみにpostsテーブルには何かしらデータが入っているのでしょうか
munequn

2019/10/02 15:48

いえ入れてません。
kokemomo.sour

2019/10/02 23:56

何かしらテストデータを入れてみてはいかがでしょうか
munequn

2019/10/03 05:24

herokuのpgを使用してpostsテーブルに投入するのですか?
kokemomo.sour

2019/10/03 08:47

Seedをご利用されるといかがでしょう
munequn

2019/10/03 09:32

はい、あと今更なんですがherokuデプロイ時にwarningが出ていたのでそちらかなと、、、追加させていただきます。
munequn

2019/10/03 15:54

Seedに初期データを投入しても結果変わらずでした。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問