Unable to complete password reset in Ruby on Rails 4 -
i trying complete password reset feature rails application. have of routes , views in place , work out problem. when user clicks on email sent system generated password reset token, taken password reset view. when user submits form (valid or not) update user record new password, view reloads no errors or not. have tried multiple configurations no luck. feel has strong parameters, can't seem work.
this url generated password reset view
http://localhost:3000/password_resets/x6hrhvsjx2nb8-u7zp9-7q/edit
this have password reset controller:
def edit @user = user.find_by_password_reset_token!(params[:id]) end def update @user = user.find_by_password_reset_token!(params[:id]) if @user.password_reset_sent_at < 2.hours.ago flash[:notice] = "password reset has expired." redirect_to(:action => 'new') elseif @user.update_attributes(user_params) flash[:success] = "password reset successful. please sign in." redirect_to(:controller => 'auth', :action => 'get_sign_in') else render(:edit) end end private def user_params params.require(:user).permit(:password, :password_confirmation) end
this form looks like
<%= form_for @user, :url => password_reset_path(params[:id]) |f| %> <div class="row"> <div class="input-field col s12"> <%= f.password_field(:password, class: 'validate') %> <%= f.label :password %> </div> </div> <div class="row"> <div class="input-field col s12"> <%= f.password_field(:password_confirmation, class: 'validate') %> <label for="password_confirmation">password confirmation</label> </div> </div> <div class="row"> <div class="col s12"> <button class="btn waves-effect waves-light blue" type="submit" name="action">update password </button> </div> </div>
here routes using
resources :password_resets match ':controller(/:action(/:id))', :via => [:get, :post]
here server logs getting during action
started put "/password_resets/82o6bwwidpug4janmcjqnq" ::1 @ 2015-07-09 06:10:49 -0500 processing passwordresetscontroller#update html parameters: {"utf8"=>"✓","authenticity_token"=>"nuwghyhpeye+fhpm8cl6ttjpttagefgynsalvvn4tg0uto3795qtrzno7bnddudl9rirki5v8vf2zp3uc2aucq==", "user"=>{"password"=>"[filtered]", "password_confirmation"=>"[filtered]"}, "id"=>"82o6bwwidpug4janmcjqnq"} user load (0.4ms) select `users`.* `users` `users`.`password_reset_token` = '82o6bwwidpug4janmcjqnq' limit 1 rendered partials/_user_errors.html.erb (0.2ms) rendered layouts/application.html.erb (86.4ms) rendered password_resets/edit.html.erb within layouts/application (92.3ms) completed 200 ok in 188ms (views: 186.2ms | activerecord: 0.4ms)
any information helpful.
Comments
Post a Comment