我已经成功地尝试了使用ajax格式在我的示例formtastic中保存ajax。Ajax:在rails3 + formtastic中检索数据
将新值添加到数据库中。但问题是我一旦通过ajax保存,就从数据库中检索列表。
怎么办?
只要我添加一条新记录,我希望我的显示列表更新。添加新记录和列出数据库数据的选项都在同一页
这是我的索引页。通过脚手架创建控制器和所有其他
<h1>Listing samples</h1>
<table>
<tr>
<th><%=t :Name%></th>
<th></th>
<th></th>
<th></th>
</tr>
<% @samples.each do |sample| %>
<tr>
<td><%= sample.name %></td>
<td><%= link_to 'Show', sample %></td>
<td><%= link_to 'Edit', edit_sample_path(sample) %></td>
<td><%= link_to 'Destroy', sample, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New Sample', new_sample_path %>
<br /><br /><br /><br /><br />
<%= semantic_form_for @sample1,:url => samples_path, :remote => true do |f| %>
<%= f.inputs do %>
<%= f.input :name %>
<% end %>
<%= f.actions do %>
<%= f.action :submit, :as => :input %>
<% end %>
<% end %>