【发布时间】:2011-07-28 20:46:28
【问题描述】:
当 Edit 操作依赖于传递的参数时,如何使用 redirect_to?
我有两个非常简单的操作编辑和更新。单击提交后,在更新后,我想将用户重定向回编辑操作。如果编辑操作需要参数,我该怎么做?
def edit
@account = Account.find_by_user_id(@params['user_id'])
end
def update
account = Account.find(params[:account_user_id])
if account.update_attributes(params[:name])
redirect_to params[:user_id].merge!(:action => :edit)
else
render :text => 'Sorry there was an error updating.'
end
end
- 这段代码搞砸了
【问题讨论】:
标签: ruby-on-rails ruby redirect parameters controller