ruby-on-rails - 设计注册表单的路线

Devise wiki 有说明 https://github.com/plataformatec/devise/wiki/How-To:-Display-a-custom-sign_in-form-anywhere-in-your-appfor在站点的任何位置创建登录表单。我想把注册表单放在主页上。

他们推荐的登录表单是这样开头的

<%= form_for("user", :url => user_session_path) do |f| %>

基于该示例和 rake 路由的输出

new_user_registration GET/users/sign_up(.:format) devise/registrations#new

我在我的网站主页上开始了这样的注册表单

<%= form_for("user", :url => new_user_registration_path) do |f| %>

当我启动服务器并尝试注册用户时,出现此错误

No route matches [POST] "/users/sign_up"

Try running rake routes for more information on available routes. 

我注意到的一件事是 rake routes 显示了对 new_user_registration 的 GET 请求,而我的错误消息显示的是 POST。不确定这是否重要。

Routes.rb



root :to => "home#index"
devise_for :users
resources :users

最佳答案

问题是这个

新用户注册路径

是错误的路径。那就是"new"行动

应该是

用户注册路径

进入“创建”操作

https://stackoverflow.com/questions/9644058/

相关文章:

php - 谷歌图像搜索 API

c# - 将文件从 Azure Blob 同步到本地

php - 根据下拉列表中的更改更改 GridView 中的数据

assembly - MIPS 从内存地址返回值

qt - 来自 QProcess 的标准输出离实时很远

javascript - window.getSelection() 的值在回调期间发生变化

ruby-on-rails - 如何创建链接以删除 Rails 中的操作(使用路径和 link_to

c# - StackOverflow 与 TryValidateObject 如果对象是有效的

php - 将 unicode 字符写入 php 中的文件 - 不重复

shell - 映射 lynx 中的键以运行 shell 命令