I했습니다이 답을 찾을 얻고, 어쩌면으로 반복 - 레일에 루비
레일에서어떻게 끌어 액티브에서 결과를 반복하는 최선의 방법은 ... 너무 간단 노력 원하는 특정 필드? 나는> <% = @posts %를 사용 나는 모든 데이터를 얻을 때, 인덱스보기에서 다음
def index
@posts = Post.find(:all)
end
.. :
나는 모든 레코드를 끌어 의견 (라는 이름의 게시물)에 대한 컨트롤러가
여기에 첫 번째 댓글입니다, 2012-05-09 : .which는보기는 의견과 created_at 필드에서 데이터를 표시되도록 내가 지금 시험을 반복 할 수있는 방법 ...
#<Post id: 1, user_id: "9", picture: nil, comments: "here's a first comment", title: nil, twitter: nl, frame: nil, created_at: "2012-05-09 04:21:16", updated_at: "2012-05-09 04:21:16"> #<Post id: 2, user_id: "9", picture: nil, comments: "here's a second comment", title: nil, twitter: "please", frame: nil, created_at: "2012-05-09 05:20:03", updated_at: "2012-05-09 05:20:03">
중대하다 4시 21분 16초
여기에 2012-05-09 5시 20분 3초
, 두 번째 주석의 나는 다음과 같은 시도하고 오류가 발생했습니다. @posts.each do |c|
에
<% @posts.each do |c| %>
<%= c.posts.comments %>
<%= c.posts.created_at %>
<% end %>
글쎄, 당신이 얻고있는 오류는 무엇입니까? – DVG