谢谢你的时间!
我得到路线routes.rb
:
get "loadreport/test"
post "loadreport/update"
控制器中的test
函数loadreport
是一个空函数:
def test
end
test.html.erb 包含:
<form action="/loadreport/update?method=post" class="button_to" method="post">
<div>
<input type="submit" value="Update" />
<textarea cols="30" id="post_body" name="comments" rows="5" maxlength=200>
</textarea>
</div>
</form>
该update
函数将更新数据库:
def update
some_database.update(params[:comments])
end
现在,当我单击Update button
in 时test.html.erb
,它会调用/loadreport/update
并跳转到update.html.erb
. 由于update.html.erb
不存在,服务器会给我如下错误:Template is missing ... blah ...
我想要实现的是:当我点击Update button
in 时test.html.erb
,它会简单地调用/loadreport/update
更新数据库,然后弹出一个消息框,上面写着“更新成功!”,而不是跳转到另一个页面。
如何更改我的代码以实现这一目标?谁能给我一些关于这个主题的想法或一些链接。谢谢!