Ruby on rails 具有不同重定向的多个保存按钮
如何在活动管理窗体上提供两个提交按钮,更新后重定向到不同的位置?只需根据参数中的提交值选择重定向。在操作块中创建操作,设置将传递到参数中的名称和值 这将在控制器块中可用,您也可以在管理文件中创建Ruby on rails 具有不同重定向的多个保存按钮,ruby-on-rails,activeadmin,Ruby On Rails,Activeadmin,如何在活动管理窗体上提供两个提交按钮,更新后重定向到不同的位置?只需根据参数中的提交值选择重定向。在操作块中创建操作,设置将传递到参数中的名称和值 这将在控制器块中可用,您也可以在管理文件中创建 f.actions do f.action :submit, :as => :button f.action :submit, :as => :button, label: 'Save and Next', button_html: {name: 'foo', value: 'bah
f.actions do
f.action :submit, :as => :button
f.action :submit, :as => :button, label: 'Save and Next', button_html: {name: 'foo', value: 'bah'}
f.action :cancel, :as => :link, label: 'Cancel', class: 'cancel', wrapper_html: {class: :cancel}
end
controller do
def update
@start = Start.find params[:id]
update! do |format|
format.html {
if params['foo']
if @start.next
redirect_to edit_admin_start_path(@start.next)
else
redirect_to admin_race_path(@start.race_id)
end
else
redirect_to admin_race_path(@start.race_id)
end
}
end
end
end
我怎样才能添加额外的按钮呢?你看了吗?不是表单还是只有两个按钮?