我有这张表添加税款。Rails 3.更改表单提交时的重定向
|Name | Rate | Description |
|IVA | 16 | something |
| | | |
| | | |
| | | |
save
所以,如果你点击保存,将保存输入的新项目。我有当我提交表单为此在taxes_controller.rb
@account = Account.find(current_user.account_id)
3.times {@account.taxes.build}
那么这个形式
<%= form_for(@account) do |f| %>
<table style="width:400px;" class="taxes">
<tr>
<th>Name</th>
<th>Rate</th>
<th>Description</th>
</tr>
<%= f.fields_for :taxes do |builder| %>
<tr>
<td><%= builder.text_field :name %></td>
<td><%= builder.text_field :rate %> %</td>
<td><%= builder.text_field :identification %></td>
</tr>
<% end %>
...
,该领域也得到保存在数据库中。问题是它重定向到账户显示页面;我知道它必须这样做,因为form_for(@account)
。
所以问题是:如何指定提交后表单要重定向的位置。在这种情况下,我想将它重定向到currect页面。
是的,但我也使用帐户控制器来创建新的帐户。但在上面的表格中,我只用它来创建新的税收。当前页面是http:// localhost:3000/taxes – leonel 2012-01-04 21:28:59
我更新了我的信息 – Robin 2012-01-04 21:47:14
我认为在accounts_controller中你的意思是class Taxes :: AccountsController' –
leonel
2012-01-04 22:13:42