2
我想就如何找到我的答案一些經驗豐富的老將建議。我知道我在我看來有太多的邏輯,而且我在重複自己,但我仍然試圖「通過做法學習」,這是關於我在什麼地方纔開始工作,我會學習如何當然,從那裏重構。查看邏輯與塊和條件軌道
我想迭代一個創建的物流,並且如果logistics_title(通過「X」,「Y」或「Z」形式傳遞)與「X」匹配,則在div中顯示X,否則不要「 t顯示任何東西。
<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>
我知道我需要寫一些輔助性的東西,但在正確的方向點幫助。 請溫柔一點,這是我學習的方式。
感謝您的關注和注意。
非常感謝你。這是我尋找的確切答案,像你這樣的人讓我堅持了這麼久。 ==是什麼讓它工作的,我想你可以說v1,我想要的應用程序。現在從您答案的第一部分開始,我可以研究將代碼應用到「最佳實踐版」中再次感謝! –