首页 > 解决方案 > 如何在 form_form 标记内使用辅助路径?

问题描述

我有两个可以让某人登录的视图文件。一个是用户内部的 new.html.erb 文件,这会创建一个全新的用户并将其登录。在登录页面上,我有一个以<%= form_for @user ... %>但提交后它将有一个“POST /users”的路由请求。我希望它要么“发布/登录”,要么至少我想适合signin_path表格,但我不知道在哪里或如何

标签: ruby-on-railsformsroutesactionform-for

解决方案


You can send a url parameter and a method parameter, with the signin_path and the method Post in your form_for.

<%= form_for @user, url: signin_path, method: :post do |f| %>

推荐阅读