我想要一些经验丰富的资深人士关于如何找到答案的建议。我知道我认为我的逻辑太多了,我在重复自己,但我仍在尝试“边做边学”,这就是我要让它发挥作用的地方,我会学习如何当然要从那里重构。
我想迭代创建的物流,如果logistic_title(通过“X”、“Y”或“Z”的形式传递)与“X”匹配,则在 div 中显示 X,否则不显示任何内容。
<div class="container-fluid">
<div class="row-fluid">
<div class="span4 hero-unit">
<% @logistics.each do |logistic| %>
<% if logistic.logistic_title = "Practice" %><br>
<%= logistic.logistic_title %>
<%= logistic.user.full_name %>
<%= logistic.content %><br>
<%= link_to time_ago_in_words(logistic.created_at) + " ago", logistic %> |
<%= link_to "Edit", edit_logistic_path(logistic) %> |
<%= link_to "Remove", logistic, method: :delete, data: { confirm: "Remove? This action cannot be undone."} %>
<% else %>
<%= puts "" %>
<% end %>
<% end %>
</div>
<div class="span4 hero-unit">
<% @logistics.each do |logistic| %>
<% if logistic.logistic_title = "Game" %><br>
<%= logistic.logistic_title %>
<%= logistic.user.full_name %>
<%= logistic.content %><br>
<%= link_to time_ago_in_words(logistic.created_at) + " ago", logistic %> |
<%= link_to "Edit", edit_logistic_path(logistic) %> |
<%= link_to "Remove", logistic, method: :delete, data: { confirm: "Remove? This action cannot be undone."} %>
<% else %>
<%= puts "" %>
<% end %>
<% end %>
</div>
<div class="span4 hero-unit">
<% @logistics.each do |logistic| %>
<% if logistic.logistic_title = "Etc." %><br>
<%= logistic.logistic_title %>
<%= logistic.user.full_name %>
<%= logistic.content %><br>
<%= link_to time_ago_in_words(logistic.created_at) + " ago", logistic %> |
<%= link_to "Edit", edit_logistic_path(logistic) %> |
<%= link_to "Remove", logistic, method: :delete, data: { confirm: "Remove? This action cannot be undone."} %>
<% else %>
<%= puts "" %>
<% end %>
<% end %>
</div>
我知道我需要写一些帮助的东西,但正确的方向会有所帮助。请温柔,这就是我的学习方式。
感谢您的关注和关注。