【发布时间】:2014-09-15 02:38:17
【问题描述】:
我仍在学习 Ruby on Rails,并尝试在该控制器中调用自定义方法 check_bike_in,并在单击按钮时将复选框和文本区域中的值传递给它。
我正在使用helper_method 调用check_bike_in,但是我不知道在单击按钮时如何调用它或如何将变量传递给控制器。
任何帮助将不胜感激。
<table class="checked_out">
<thead>
<tr>
<th>User</th>
<th>Bike</th>
<th>Checkout time</th>
</tr>
</thead>
<tbody>
<% @checkouts.each do |checkout| %>
<tr>
<td class="user"><%= checkout.user_id %></td>
<td class="bike_number"><%= checkout.bike_id %></td>
<td><button onclick="$('#<%= checkout.id %>').toggle()">Check Bike In</button></td>
</tr>
<tr style="display: none" id = "<%= checkout.id %>">
<td class="needs_reapir_checkbox"><input type="checkbox"> Needs Repair</td>
<td class="repair_textbox"><textarea rows="1" cols="50"></textarea></td>
<td><button onclick="">Check In</button></td>
</tr>
<% end %>
</tbody>
</table>
【问题讨论】:
标签: javascript html ruby-on-rails ruby helper