“映射”问题出在哪里?带有此表单的Rails操作的URL? [英] What is wrong in "mapping" URLs to Rails actions with this form?
问题描述
在 app / views / users / reset.html.erb 文件中,我有以下代码:
In 'app/views/users/reset.html.erb' file I have this code:
<%= form_tag( send_reset_users_path, :method => :post ) do %>
<%= text_field_tag :email %>
<%= submit_tag("Send") %>
<% end %>
在'app / controllers / * users_controller.rb *'中,我有以下代码:
In 'app/controllers/*users_controller.rb*' I have this code:
def reset
respond_to do |format|
format.html # reset.html.erb
end
end
def send_reset
...
end
在'config / routes.rb '中,我有以下代码:
In 'config/routes.rb' I have this code:
resources :users do
collection do
get 'reset'
get 'send_reset'
end
end
当我提交表单时,出现错误:没有路线匹配 /用户/ send_reset(浏览器URL变为'... / users / send_reset')。 出什么问题了?如何将URL映射到Rails操作?
When I submit the form I get the error: "No route matches "/users/send_reset"" (browser URL becomes '.../users/send_reset'). What is wrong? How can I "map" URLs to Rails actions?
PS:我认为问题出在配置/路由中。 rb ...
P.S.: I think the problem is in "config/routes.rb"...
推荐答案
问题出在这里:method => :post
和 get'send_reset'
,据我所知,当控制器要求GET方法
the problem is here :method => :post
and get 'send_reset'
, in my opinion you are trying to POST parameters when your conntroller expect GET method
这篇关于“映射”问题出在哪里?带有此表单的Rails操作的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!