基本的な質問をさせていただきます。
前提・実現したいこと
ruby on rails で初心者向けのブログ投稿機能をつくり、コメント投稿機能を実装したいです。
発生している問題・エラーメッセージ
app/views/posts/show.html.erb where line #24 raised:
SQLite3::SQLException: no such column: comments.post_id: SELECT "comments".* FROM "comments" WHERE "comments"."post_id" = ?
このエラーメッセージの意味がわからず、困っています。commentのカラムが存在していないということなのでしょうか?
また、カラムが存在していないとすると、どこをどう直せばいいのでしょうか?
よろしくお願いします。
該当のソースコード
app/views/posts/show.html.erb where line #24 raised:
<p id='notice'><%= notice %></p>
<P>
<strong>Category:</strong>
<%= @post.category_id %>
</P>
<p>
<strong>Title:</strong>
<%= @post.title %>
</p>
<p>
<strong>Body:</strong>
<%= @post.body %>
</p>
<p>
<strong>Created_at:</strong>
<%= @post.created_at %>
</p>
<h3>comments</h3>
<% @comments.each do |comment| %>
<div>
<p><%= comment.body %></p>
</div>
<% end %>
<%= form_for([@post, @post.comments.build]) do |f| %>
<div class="field">
<%= f.label :body %><br>
<%= f.text_field :body %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。