2012-04-02 60 views
0

我使用的培训就业部博客宝石制作的表。它以这种方式呈现特定主题的帖子。Rails的:从一个集合

<%= render :partial => "forem/posts/post", :collection => @posts %> 

有没有办法让输出显示在表格中?我已将<td>标记放在下面的部分中,我想分解成一个表格。

行名字,我想是姓名,张贴在,信息,在回复和行动。

我想我也许可以做这样的事情

@posts.each do |p| 

<tr> 
p 
</tr> 

,但我无法弄清楚如何得到它的工作

部分

<a name='post-<%= post.id %>'></a> 
<div id='post_<%= post.id %>' class='post <%= cycle('odd', 'even') -%>'> 


    <td> 
     Name:<%= link_to_if Forem.user_profile_links, post.user, [main_app, post.user] %> 
    </div> 
    <div class='icon'><%#= avatar(post.user, :size => 60) %></div> 

    </td> 



<td> 
    <a href='#post-<%= post.id %>'> 
     <time datetime="<%= post.created_at.to_s(:db) -%>"><%= "#{time_ago_in_words(post.created_at)} #{t("ago")}" %></time> 
    </a> 
</td> 
<td> 
    <%= forem_format(post.text) %> 
</td> 

<td> 
    <% if post.reply_to %> 
     <span class='in_reply_to'> 
     <%= link_to "#{t("forem.post.in_reply_to")} #{post.reply_to.user}", "#post-#{post.reply_to.id}" %> 
     </span> 
    <% end %> 
</td> 

<td> 

    <ul class='actions'> 
     <% if forem_user %> 
     <% if can?(:reply, @topic) %> 
      <% if @topic.can_be_replied_to? %> 
      <li><%= link_to t('reply', :scope => 'forem.topic'), new_topic_post_path(@topic, :reply_to_id => post.id) %></li> 
      <% end %> 
      <% if @topic.can_be_replied_to? %> 
      <li><%= link_to t('quote', :scope => 'forem.topic'), new_topic_post_path(@topic, :reply_to_id => post.id, :quote => true) %></li> 
      <% end %> 
     <% end %> 
     <% if post.owner_or_admin?(forem_user) %> 
      <% if can?(:edit_post, @topic.forum) %> 
      <li><%= link_to t('edit', :scope => 'forem.post'), edit_topic_post_path(@topic, post) %></li> 
      <% end %> 
      <li><%= link_to t('delete', :scope => 'forem.topic'), topic_post_path(@topic, post), :method => :delete, :confirm => t("are_you_sure") %></li> 
     <% end %> 
     <% end %> 
    </ul> 

</td> 

    </div> 
</div> 
+0

是什么输出看起来像现在呢? – Rahul 2012-04-02 04:33:08

+0

这个论坛的各个部分都附带了不同的课程,但是我删除了他们,因为他们对我的技能有点头痛。这就是为什么我想要使用表格,并且只将OPD中的'td'标签放入OP中的部分内容,以显示我希望如何组织表格。我想我也许可以这样做@ posts.each做​​... – Leahcim 2012-04-02 04:42:49

+0

我的意思是,你能之前共享/截图我们来看看后? – Rahul 2012-04-02 04:52:32

回答

0

您是否尝试过加入而不是在部分代码的开始部分?也许是一个循环之前的帖子?

相关问题