Route a form to new controller action in Ruby on Rails

前端 未结 3 1651
遥遥无期
遥遥无期 2021-01-25 17:23

I am relatively new to Ruby on Rails, and am trying to set up a form with a new action on an existing controller.

My existing model and controller is called \'projects\'

3条回答
  •  执笔经年
    2021-01-25 17:38

    Two places to revise:

    1. Route. Better to use static route for POST without parameter, and specify POST

      match 'projects/queue' => 'projects#queue', via: :post
      
    2. Form tag. You need to specify the path

      <%= form_tag "projects/queue", method: :post do %>
      

      Better not to use div id, if you have to, use it like this

      <%= form_tag "projects/queue", method: :post, html: {id: "select_user"} do %>
      

提交回复
热议问题