我是RoR中开发Web应用程序的新手,我需要一些jQuery帮助。如何在轨道上使用jquery在ruby中的表格
我有一个包含消息表和两个按钮的网页,用于进行审核 - 接受和拒绝消息。
... /视图/消息/ index.html.erb
<div class="container">
<h1>Moderate</h1>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Client</th>
<th>№</th>
<th>Date</th>
<th>Content</th>
<th>Tariff</th>
<th>FromDate</th>
<th>TillDate</th>
<th>Cost</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<%= render @messages %>
</tbody>
</table>
<%= will_paginate @messages %>
</div>
... /视图/消息/ _message.html.erb
<tr>
<% if current_user.admin? %>
<th><%= message.user.name %></th>
<% end %>
<th><%= message.id %></th>
<th><%= message.created_at %></th>
<th><%= image_tag message.content_url(:thumb) if message.content? %></th>
<th><%= message.tariff %></th>
<th><%= message.fromdate %></th>
<th><%= message.tilldate %></th>
<th><%= message.cost %></th>
<th><%= message.status %>
<% if current_user.admin? && message.status=="Moderating" %>
<div class="btn-group" id="btn-group-<%= message.id %>">
<button type="button" class="btn btn-success">Accept</button>
<button type="button" class="btn btn-danger">Decline</button>
</div>
<% end %>
</th>
</tr>
当单击按钮“接受”我需要在数据库(sqlite3)中将相应的消息状态更改为“已接受”,表格的相应行应为引导.success样式,并且两个按钮都隐藏。
当点击按钮“拒绝”时,我需要在数据库中将相应的消息状态更改为“拒绝”,相应的表格行应该是bootstrap .danger样式,并且两个按钮都隐藏起来。
message.status has string type。
我将不胜感激解决方案的例子。
谢谢,布拉德!我已经将解决方案适用于我的任务,并且几乎按需要工作。如果你不介意 - 请给我一些提示。 – ayevdoshenko
如何在同一时间更改消息状态单元格? – ayevdoshenko
很高兴它起作用,你想改变它到什么程度? – Brad