Search code examples
ruby-on-railsdevisesimple-formbasic-authentication

Devise User can't be edited


I have a Rails app using Devise for user authentication. I'm pretty sure the Devise edit user feature worked previously, but for some reason, edit/update doesn't work anymore. When I click "Update", the page just refreshes on the form. It also displays "Please review the problems below:" even though I've entered everything correctly.

The cancel account function works perfectly, however. Could the issue be the url path? If so, why does canceling the account work, while updating doesn't? I do have the user model nested within another model, but I've tried variations on the url path, none of which have worked.

Below is the form page generated by Devise and using simple_form:

.col-md-5.col-md-offset-2
  %h2
    Edit #{resource_name.to_s.humanize}
  = simple_form_for(resource, as: resource_name, url: registration_path(resource_name)    , html: { method: :put }) do |f|
    = f.error_notification
    .form-inputs
      = f.input :email, required: true, autofocus: true
      - if devise_mapping.confirmable? && resource.pending_reconfirmation?
        %p
          Currently waiting confirmation for: #{resource.unconfirmed_email}
      = f.input :password, autocomplete: "off", hint: "leave it blank if you don't     want to change it", required: false
      = f.input :password_confirmation, required: false
      = f.input :current_password, hint: "we need your current password to confirm     your changes", required: true
    .form-actions
      = f.button :submit, "Update"
  %h3 Cancel my account
  %p
    Unhappy? #{link_to "Cancel my account", registration_path(resource_name), data: {     confirm: "Are you sure?" }, method: :delete}
  = link_to "Back", root_path

Update:

Here's the printout from development.log:

Started PUT "/users" for 127.0.0.1 at 2014-12-14 00:05:07 -0500
Processing by Users::RegistrationsController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"Zhtv8rbmwIDuZO7Tv/0db7tSIGfGUEW56fqPKzkgQSo=", "user"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "current_password"=>"[FILTERED]"}, "commit"=>"Update"}
  [1m[36mUser Load (0.3ms)[0m  [1mSELECT  `users`.* FROM `users`  WHERE `users`.`id` = 16  ORDER BY `users`.`id` ASC LIMIT 1[0m
  [1m[35mUser Load (0.2ms)[0m  SELECT  `users`.* FROM `users`  WHERE `users`.`id` = 16 LIMIT 1
  [1m[36m (0.2ms)[0m  [1mBEGIN[0m
  [1m[35m (0.1ms)[0m  ROLLBACK
  Rendered devise/registrations/edit.html.haml within layouts/application (4.3ms)
  Rendered common/_login.html.haml (0.5ms)
Completed 200 OK in 328ms (Views: 175.1ms | ActiveRecord: 0.7ms)

Here's my routes.rb file. I do have Users listed twice.

devise_for :users

root 'welcome#index'

resources :wedding_checklists do
  resources :users
  resources :checklist_items
end

Solution

  • It seems to me an error has occurred but was not shown. Please add <%= devise_error_messages! %> to your form and let me know what errors are printed out.