我在 if else 方法中有 2 个按钮,第一个按钮假设允许用户将布尔值从 false 更改为 true。然后,如果模型显示它是真的,它将显示另一个按钮,即删除按钮。我无法让切换按钮(顶部)正常工作,删除很好。这是现在的情况。
def which_button(reportapproval)
if reportapproval.user_approved == false
button_to "Approve this Manager?", { controller: "users/reportapprovals", id: @reportapproval.id, action: "#not sure what goes here" }, method: :#not sure what goes here, data: {confirm: "Are you sure you want to give this manager access to your report?" }
else
button_to "Remove this Manager", { controller: "users/reportapprovals", id: @reportapproval.id, action: "destroy" }, method: :delete, data: {confirm: "Are you sure you want to remove this manager's access to your report?" }
end
end
但我不断收到错误 Post route no found ,我知道这是不对的。我希望这可以在 reportapproval 模型中切换一个布尔值。请告诉我我需要做什么。