How to call a controller method from a button in rails 4

前端 未结 5 567
日久生厌
日久生厌 2020-12-15 17:30

So I feel really stupid right now, but I can\'t seem to find an answer.

So I have a method which needs to be called EXACTLY once, and since this is only the experime

5条回答
  •  忘掉有多难
    2020-12-15 18:27

    It's as easy as adding method_controller_path to the HTML.
    For instance, I have a route filaments/new, and to add a button that links to it from any view:
    <%= button_to "Add", new_filament_path, method: :get %>

提交回复
热议问题