Noob需要一些幫助。我創建一個苦差事圖表爲我的孩子應該看起來像一個在線版本:倒在頂部的X軸,Y軸和天(週日,週一...)上市Rails button_to或link_to圖片
http://learningandeducationtoys.guidestobuy.com/i-can-do-it-reward-chart
家務。讓孩子們點擊並接收完成的雜事的明星包裝盒。
的瑣事/ index.html.erb表是難看代碼(對不起):
清單瑣事
<table>
<th><%= "" %></th>
<th><%= "SUN" %></th>
<th><%= "MON" %></th>
<th><%= "TUES" %></th>
<th><%= "WED" %></th>
<th><%= "THURS" %></th>
<th><%= "FRI" %></th>
<th><%= "SAT" %></th>
<% @chores.each do |chore| %>
<tr class="<%= cycle('list-line-odd', 'list-line-even') %>">
<% ##TODO.. Fix to be sure to link "post" action to "show" child. %>
<td>
<%= image_tag(chore.image_url, :class => 'list-image') %>
<dt><%=h chore.title %></dt>
</td>
<td class="button"><%= button_to "Add to Wallet", wallets_path(:chore_id => chore, :child_id => session[:child_id]),
:remote => true %></td>
<td class="button"><%= button_to "Add to Wallet", wallets_path(:chore_id => chore, :child_id => session[:child_id]),
:remote => true %></td>
<td class="button"><%= button_to "Add to Wallet", wallets_path(:chore_id => chore, :child_id => session[:child_id]),
:remote => true %></td>
<td class="button"><%= button_to "Add to Wallet", wallets_path(:chore_id => chore, :child_id => session[:child_id]),
:remote => true %></td>
<td class="button"><%= button_to "Add to Wallet", wallets_path(:chore_id => chore, :child_id => session[:child_id]),
:remote => true %></td>
<td class="button"><%= button_to "Add to Wallet", wallets_path(:chore_id => chore, :child_id => session[:child_id]),
:remote => true %></td>
<td class="button"><%= button_to "Add to Wallet", wallets_path(:chore_id => chore, :child_id => session[:child_id]),
:remote => true %></td>
</tr>
<% end %>
</table>
</div>
每個雜項的每一天上面創建「添加到電子錢包」的按鈕。錢包是兒童和家務桌之間的連接表。兩個問題:
- 如何將按鈕切換到表格中,當點擊時,轉向星星圖像(按照示例)?
- 我如何重構表中的代碼,所以我不違反DRY規則?
真棒。謝謝,我感謝有關這兩個問題的幫助。 – chris 2011-05-11 21:09:51