Ruby on rails 当操作依赖于所传递的参数时,如何使用重定向到?
当编辑操作依赖于所传递的参数时,如何使用重定向到 我有两个非常简单的操作:编辑和更新。单击“提交”后,在更新之后,我希望将用户重定向回编辑操作。如果编辑操作需要参数,如何执行此操作Ruby on rails 当操作依赖于所传递的参数时,如何使用重定向到?,ruby-on-rails,ruby,redirect,parameters,controller,Ruby On Rails,Ruby,Redirect,Parameters,Controller,当编辑操作依赖于所传递的参数时,如何使用重定向到 我有两个非常简单的操作:编辑和更新。单击“提交”后,在更新之后,我希望将用户重定向回编辑操作。如果编辑操作需要参数,如何执行此操作 def edit @account = Account.find_by_user_id(@params['user_id']) end def update account = Account.find(params[:account_user_id]) if accou
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
- 这个密码爆炸了
redirect_to edit_account_path( account.id, :user_id => params[:user_id])
我假设您在这里将路由声明为资源:帐户请尝试以下操作:
redirect_to edit_account_path( account.id, :user_id => params[:user_id])
我假设您在这里将您的路线声明为resources:accounts