我有以下代码:遍历Rails中的Active Record的关系3.2
@items = QuestionGroup.search(params[:search]).limit(50)
这会返回一个ActiveRecord关系。在我要来遍历它的观点,所以我使用:
<% if @items.present? %>
<%= @items.each do |r| %>
<%= div_for r do %>
<div><%= r.subject %></div>
<% end %>
<% end %>
<% end %>
这确实打印r.subject的看法,但然后将其与整个关系遵循它。例如
the pipe
[#<QuestionGroup id: **, subject: "the pipe", created_at: "*******", updated_at: "******"]
这是为什么,我该如何解决?
'<%= @ items.each do | r | %>'到'<%@ items.each do | r | %>' – Nithin 2014-11-22 11:19:46