作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我现在觉得很愚蠢,但我似乎找不到答案。
所以我有一个方法需要被精确调用一次,由于这只是实验阶段,我决定一个简单的按钮就足够了。但是,我似乎无法找出如何/是否可以通过单击按钮简单地调用该方法。
方法在 home_controller.rb 中,按钮在 index.html.erb 中
有任何想法吗?还是这不是我能做的?
最佳答案
<%= form_tag home_action_path, method: :post do %>
<%= submit_tag 'Call Action' %>
<% end %>
<%= link_to 'Call Action', home_action_path, method: :post %>
<%= button_to 'Call Action', home_action_path, method: :post %>
post 'home/action'
关于ruby-on-rails - 如何从 rails 4 中的按钮调用 Controller 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17243200/
我是一名优秀的程序员,十分优秀!