title: ArgumentError: When assigning attributes, you must pass a hash as an argument
body: <p>I'm upgrading from Rails 4 to 4.2. I have a users controller that looks something like this:</p>
  <h1>user_controller.rb</h1>
  <pre><code>class UsersController &lt; ApplicationController
    
    def new
    end
  
    def edit
    end
  
    protected
  
    def create_with_token
      @user.attributes = params[:user]
      @user.validate_password = true
  
      if @user.save
        
      else
        render 'new'
      end
    end
  
    private
  
    def user_params
      params.require(:user).permit(
        :email, :first_name, :last_name, :password, :more_attributes
      )
    end
  end
  </code></pre>
  <p>I'm not sure yet if this has something to do with strong_params. But as far as I know <code>params[:user]</code> returns a hash. So why do I get <code>ArgumentError: When assigning attributes, you must pass a hash as an argument.</code> on <code>@user.attributes = params[:user]</code>?</p>
  <p>I checked the <a href="https://github.com/rails/rails/blob/master/activemodel/lib/active_model/attribute_assignment.rb#L28" rel="nofollow noreferrer">rails code</a> and found:</p>
  <pre><code>def assign_attributes(new_attributes)
    if !new_attributes.respond_to?(:stringify_keys)
      raise ArgumentError, &quot;When assigning attributes, you must pass a hash as an argument.&quot;
    end
    return if new_attributes.empty?
  
    attributes = new_attributes.stringify_keys
    _assign_attributes(sanitize_for_mass_assignment(attributes))
  end
  </code></pre>
  <p>From here, assuming <code>#assign_attributes</code> replaced <code>#attributes</code> (It's actually an <a href="https://apidock.com/rails/ActiveRecord/AttributeAssignment/attributes%3D" rel="nofollow noreferrer">alias</a> for it. I can infer that <code>params[:user]</code> is not responding to <code>#stringify_keys</code>. But why? How? What's the work around?</p>