当用户单击“注销”时,我的应用程序正在运行 destroy_user_session_path 并且运行良好。但是,我需要在 destroy_user_session_path 发生之前从我的 carts_controller 运行 destroy 方法。单击注销按钮时运行这两个操作的最佳方法是什么?(我在应用程序中找不到设计控制器或会话控制器)
application.html.erb - 销毁注销按钮的调用
<%= link_to "Logout", destroy_user_session_path, method: :delete, :class => 'navbar-link boldLinks btn btn-primary' %>
Run Code Online (Sandbox Code Playgroud)
购物车/show.html.erb - 单击一个按钮时,在销毁之前需要删除/清空购物车调用
<%= link_to 'Empty Cart', @cart, method: :delete, data: {confirm: 'Are you sure you want to empty your cart?'}, :class => 'btn btn-danger whiteText' %>
Run Code Online (Sandbox Code Playgroud)