I'm doing the Michael Hartl rails tutorial and trying to implement the password reset functionality but the request that sends the password reset form (The form where you reset your password) looks like /password_resets.SOLceKJXoax55zSBAfAhTQ which rails then says: No route matches [PATCH] "/password_resets.SOLceKJXoax55zSBAfAhTQ" In the tutorial we are asked to use this route: resources :password_resets, only: [:new, :create, :edit, :update] But I get that error message.
This is how my password_resets_controller.rb update method looks like:
def update
if password_blank?
flash.now[:danger] = "Password can't be blank"
render 'edit'
elsif @user.update_attributes(user_params)
log_in @user
flash[:success] = "Password has been reset."
redirect_to @user
else
render 'edit'
end
end
Any idea how does my method or my route is causing that error? Thank you in advance.
Update: Adding my Reset Password view (password_resets\edit.html.erb)
<% provide(:title, 'Reset Password') %>
<h1>Reset Password</h1>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<%= form_for(@user, url: password_resets_path(params[:id])) do |f| %>
<%= render 'shared/error_messages' %>
<%= hidden_field_tag :uemail, @user.uemail %>
<%= f.label :password %>
<%= f.password_field :password, class: 'form-control' %>
<%= f.label :password_confirmation, "confirmation" %>
<%= f.password_field :password_confirmation, class: 'form-control' %>
<%= f.submit "update password", class: "btn btn-primary" %>
<% end %>
</div>
</div>
/password_resets/SOLceKJXoax55zSBAfAhTQ. Can you post the view code that renders the form? - ihaztehcodezpassword_reset_path(params[:id])will work for you - Muntasim