3 回答

TA貢獻(xiàn)1804條經(jīng)驗(yàn) 獲得超3個(gè)贊
只需將它們附加到選項(xiàng):
redirect_to controller: 'thing', action: 'edit', id: 3, something: 'else'
會(huì)屈服 /thing/3/edit?something=else

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊
如果您正在使用RESTful資源,則可以執(zhí)行以下操作:
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貢獻(xiàn)1884條經(jīng)驗(yàn) 獲得超4個(gè)贊
您可以使用flash參數(shù)將任意對(duì)象傳遞到模板。
redirect_to :back, flash: {new_solution_errors: solution.errors}
然后通過(guò)哈希在模板中訪問(wèn)它們。
<% flash[:new_solution_errors].each do |err| %>
添加回答
舉報(bào)