3 回答
TA贡献1816条经验 获得超4个赞
只需将它们附加到选项:
redirect_to controller: 'thing', action: 'edit', id: 3, something: 'else'
会屈服 /thing/3/edit?something=else
TA贡献2036条经验 获得超8个赞
如果您正在使用RESTful资源,则可以执行以下操作:
redirect_to action_name_resource_path(resource_object, param_1: 'value_1', param_2: 'value_2')
or
#You can also use the object_id instead of the object
redirect_to action_name_resource_path(resource_object_id, param_1: 'value_1', param_2: 'value_2')
or
#if its a collection action like index, you can omit the id as follows
redirect_to action_name_resource_path(param_1: 'value_1', param_2: 'value_2')
#An example with nested resource is as follows:
redirect_to edit_user_project_path(@user, @project, param_1: 'value_1', param_2: 'value_2')
TA贡献1825条经验 获得超6个赞
您可以使用flash参数将任意对象传递到模板。
redirect_to :back, flash: {new_solution_errors: solution.errors}
然后通过哈希在模板中访问它们。
<% flash[:new_solution_errors].each do |err| %>
- 3 回答
- 0 关注
- 838 浏览
添加回答
举报