나는 루비 온 레일스 튜토리얼을 따르고있다. 게시물에 캡션 옆에 대괄호 안에 내 게시물 정보가 표시됩니다. 고칠 방법을 알고 있다면 도와주세요! 예 =>레일에 게시물 정보가 표시되는 대괄호?
"! PHOTOGRAM 첫 소식 [# < 우편 번호 : 1, 자막"PHOTOGRAM 첫 포스트 "created_at :"2017년 9월 4일 3시 24분 25초 "updated_at : "2017-09-04 03:24:25", image_file_name : "instagram.jpg", image_content_type : "image/jpeg", image_file_size : 64169, image_updated_at : "2017-09-04 03:24:24 ">]"
소식 제어기
class PostsController < ApplicationController
def index
@posts = Post.all
end
def new
@post = Post.new
end
def create
@post = Post.create(post_params)
redirect_to posts_path
end
private
def post_params
params.require(:post).permit(:image, :caption)
end
end
,745,
응용 프로그램/조회/게시물/index.html.erb
<h1> Photogram </h1>
<%= @posts.each do |post| %>
<%= image_tag post.image.url(:medium) %>
<%= post.caption %>
<% end %>
new.html.erb
<%= form_for(@post) do |f| %>
<%= f.file_field :image %>
<%= f.text_field :caption %>
<%= f.submit %>
<% end %>
(이 대답은 그냥 발언과 설명과 함께, 자신의 의견에 말을 "최대 pleaner"기본적으로) @ posts.each do | post | %>'는'<%'을 여는 태그로 사용해야합니다. –