title: How to validate password with confirm password [Rails 3.2]
body: <p><strong>How to validate password with confirm password in rails 3.2</strong></p>
  
  <p><strong>my code not work</strong></p>
  
  <p><strong>you can tell where my error</strong></p>
  
  <p>I've tried many variations changing the code in the controller.</p>
  
  <p>Password saves but not validated to the password confirm field and password field.</p>
  
  <p>help me please, help me )))</p>
  
  <p><strong>views</strong></p>
  
  <pre><code>&lt;%= form_for :password, :url =&gt; { :action =&gt; "change_password" }, :id =&gt; @user do |f| %&gt; 
  &lt;% if @user.errors.any? %&gt;
      &lt;div class="error_messages"&gt;
        &lt;h2&gt;Form is invalid&lt;/h2&gt;
        &lt;ul&gt;
          &lt;% for message in @user.errors.full_messages %&gt;
            &lt;li&gt;&lt;%= message %&gt;&lt;/li&gt;
          &lt;% end %&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;% end %&gt;
  &lt;%= f.password_field :password %&gt;
  &lt;%= f.password_field :password_confirmation %&gt;
  &lt;%= f.submit "Save", :class =&gt; "button blue" %&gt;
  &lt;% end %&gt; 
  </code></pre>
  
  <p><strong>User Controller</strong></p>
  
  <pre><code>  def change_password
      @page_title = "Changing Zetfon account password"
      @user = current_user
      if request.post?
  
         @user.password = Digest::SHA1.hexdigest(params[:password][:password]) 
      if @user.save
          redirect_to :action =&gt; 'profile'
          flash[:status] = "Your password was changed. Next time you sign in use your new password."
        else
       flash[:status] = _('Your password not changed')
          render :action =&gt; "change_password"
        end
      end
    end
  </code></pre>
  
  <p><strong>User Model</strong></p>
  
  <pre><code>  validates_confirmation_of :password
    attr_accessible :password_confirmation
    attr_accessor :password
  </code></pre>