form_for> f.submit,如何仅在更新操作时发出警报。

时间:2017-01-23 09:33:45

标签: ruby-on-rails ruby

如何设置它以便它只在更新操作时弹出而不是创建?

= f.submit, data: { confirm: "you are about to update object, are you sure?" }

1 个答案:

答案 0 :(得分:1)

尝试这样的事情

= f.submit, data: action == 'edit' ? { confirm: "you are about to update object, are you sure?" } : {}