3 回答

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

TA貢獻1813條經(jīng)驗 獲得超2個贊
如果您正在使用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貢獻1884條經(jīng)驗 獲得超4個贊
您可以使用flash參數(shù)將任意對象傳遞到模板。
redirect_to :back, flash: {new_solution_errors: solution.errors}
然后通過哈希在模板中訪問它們。
<% flash[:new_solution_errors].each do |err| %>
添加回答
舉報