Note that there are some explanatory texts on larger screens.

plurals
  1. PODevise 3 (rails 4) can't update user without password
    primarykey
    data
    text
    <p>I'm trying to update a user without having to provide a password, but approaches that worked on older devise/rails versions no longer work with devise 3 and rails 4 strong parameters.</p> <p>I'm using my user_controller to update but I have also tried using a custom devise registration controller with devise_parameter_sanitizer, without success.</p> <p>The form does not require a password (has no password field) and the user_controller handling the update looks like so:</p> <pre><code># PATCH/PUT /users/1 def update if user_params[:password].blank? Rails.logger.info "entered if statement" user_params.delete :password user_params.delete :password_confirmation Rails.logger.info(user_params.inspect) end @user = current_user if @user.update(user_params) redirect_to @user, notice: 'User was successfully updated.' else Rails.logger.info(@user.errors.inspect) render action: 'edit' end end private def user_params params.require(:user).permit(:screen_name, :full_name, :email, :about, :location, :profile_pic, :password, :password_confirmation, :current_password) end </code></pre> <p>.. the log after a submit looks like:</p> <pre><code>Started PATCH "/users/13" for 127.0.0.1 at 2013-05-29 11:18:18 +0100 Processing by UsersController#update as HTML Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"20avah2OzaOVubAiam/SgvbYEQ4iijEWQqmNo7xD4rY=", "user"=&gt;{"screen_name"=&gt;"Darcbar", "full_name"=&gt;"Barry Darcy", "about"=&gt;"", "location"=&gt;"", "website_url"=&gt;"", "twitter_username"=&gt;"", "email"=&gt;"barry@gmail.com"}, "commit"=&gt;"Save changes", "id"=&gt;"13"} User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = 13 ORDER BY "users"."id" ASC LIMIT 1 Entered if statement... {"screen_name"=&gt;"Darcbar", "full_name"=&gt;"Barry Darcy", "email"=&gt;"barry@gmail.com", "about"=&gt;"", "location"=&gt;"", "twitter_username"=&gt;"", "website_url"=&gt;""} (0.2ms) BEGIN User Exists (0.8ms) SELECT 1 AS one FROM "users" WHERE ("users"."email" = 'barry@gmail.com' AND "users"."id" != 13) LIMIT 1 (0.2ms) ROLLBACK #&lt;ActiveModel::Errors:0x007fedf45bb640 @base=#&lt;User id: 13, username: "darcbar", full_name: "Barry Darcy", about: "", location: "", email: "barry@gmail.com", encrypted_password: "$2a$10$Mb4zsRPPqZ9CYz0zdLMBU.62NyIk/T8s6Zw/uRTwWov3...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 9, current_sign_in_at: "2013-05-28 17:51:20", last_sign_in_at: "2013-05-28 16:42:52", current_sign_in_ip: "127.0.0.1", last_sign_in_ip: "127.0.0.1", authentication_token: nil, created_at: "2013-05-27 14:03:41", updated_at: "2013-05-28 17:51:20", screen_name: "Darcbar", profile_pic_file_name: nil, profile_pic_content_type: nil, profile_pic_file_size: nil, profile_pic_updated_at: nil&gt;, @messages={:password=&gt;["please enter a password with at least 5 characters", "please enter a password with at least 5 characters"]}&gt; Rendered users/edit.html.haml within layouts/application (3.0ms) Rendered partials/head/_user_options.haml (1.8ms) Completed 200 OK in 74ms (Views: 12.1ms | ActiveRecord: 1.7ms) </code></pre> <p>Does anyone know why the password errors are present?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload