写真投稿したいのですが、上手く行きません。
エラー内容
Refile::InvalidID in Posts#index
Showing /home/vagrant/work/town_i/app/views/posts/index.html.erb where line #6 raised:
Refile::InvalidID
Extracted source (around line #6):
4
5
6
7
8
9
<table> <tr> <td><%= attachment_image_tag post, :image, :fill, 200, 100, format: 'jpg' %></td> <td><span><%= post.town_name %></span></td>
Rails.root: /home/vagrant/work/town_i
Application Trace | Framework Trace | Full Trace
app/views/posts/index.html.erb:6:in block in _app_views_posts_index_html_erb__480987085213690621_70012533613180' app/views/posts/index.html.erb:3:in
_app_views_posts_index_html_erb__480987085213690621_70012533613180'
Request
newページ
<h1>口コミ投稿</h1><%= form_for(@post) do |f| %> <p>場所</p> <%= f.text_field :town_name %> <p>コメント</p> <%= f.text_area :comment %> <h4>画像</h4> <%= f.attachment_field :image %> <%= f.submit '投稿する' %> <% end %>
indexページ
class PostsController < ApplicationController
def new @post = Post.new
end
def create
@post = Post.new(post_params)
@post.customer_id = current_customer.id
@post.save
redirect_to posts_path
end
def index
@posts = Post.page(params[:page]).per(5)
end
def show
@post = Post.find(params[:id])
@post_comment = PostComment.new
end
def destroy
@post = Post.find(params[:id])
@post.destroy
redirect_to post_path
end
private def post_params params.require(:post).permit(:town_name, :image, :comment) end
end
よろしくお願い致します。> 引用テキスト
あなたの回答
tips
プレビュー