0
我想在rails中实现一个被遗忘的密码解决方案。我有一个表格供用户输入他们注册帐户的电子邮件地址,我打算让邮件程序给他们发送一封唯一的URL,将他们链接到密码重置页面。在轨道忘记密码
我的config/routes.rb中文件有以下途径:
resources :users do
collection do
get :lost_password #the account-email submisison form url
get :reset_password #a url for the function that sends the response email
end
end
当我从控制台运行耙路线,我得到的路径我想:
lost_password_users GET /users/lost_password(.:format) {:action=>"lost_password", :controller=>"users"}
reset_password_users GET /users/reset_password(.:format) {:action=>"reset_password", :controller=>"users"}
users GET /users(.:format) {:action=>"index", :controller=>"users"}
POST /users(.:format) {:action=>"create", :controller=>"users"}
但!当用户点击了提交在下面的代码中列出的表格按钮:
<h3>Reset Password</h3>
<%= form_for(:user, :url => reset_password_users_path) do |f| %>
<p>Enter the email address you used to register for this site.</p></br>
<div class="field">
<%= f.label :email %> </br>
<%= f.text_field :email %>
</div>
<div class="actions">
<%= f.submit "Send Email" %>
</div>
<% end %>
我得到一个
没有路由匹配 “/用户/ reset_password”
通过错误ActionController。
我呢,其实,有意见,并同时为lost_password_users_path和reset_password_users_path定义控制器的功能,所以我很困惑,为什么我会遇到这样的路由错误。
我有两个问题:
- 为什么会ActionController的提出这个错误,当我有明确的路径,方法和观点界定?
- 是否有其他人在RoR中实现了密码重置,并且您能否借鉴任何有关这种方法是否良好的方法?
在此先感谢!
由于改变
get :reset_password
到post :reset_password
,普拉!仍在努力理解这一切如何联系在一起的不断增长的痛苦。 = P – ArcGhost 2011-05-19 11:05:12