答えを見つける方法について、ベテランのアドバイスをお願いします。私は自分の見解に論理が多すぎることを知っています。繰り返しますが、私はまだ「実行して学ぶ」ことを試みています。もちろんそこからリファクタリングします。
作成されたロジスティクスを反復処理したいのですが、("X"、"Y"、または "Z" のいずれかの形式で渡された) ロジスティクス_タイトルが "X" と一致する場合は、X を div に表示し、それ以外の場合は何も表示しません。
<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>
私はいくつかのヘルパーを書く必要があることを知っていますが、正しい方向へのポイントが役立ちます. 優しくしてください、これが私が学ぶ方法です。
ご覧いただきありがとうございます。