title: Rails 4: validation prevents delete
body: <p>I am trying to add validation to my User model:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
      validates :first_name, :last_name, :email, :password, presence: true
  </code></pre>
  
  <p>When the validation is in place, it prevents me from being able to "delete"... I'm soft deleting users by setting an <code>is_delete</code> field to <code>1</code>. I suspect this is related to the fact that I don't actually store a <code>:password</code>. Instead, I have callbacks that salt and hash the entered password and save them into those respective fields (hashed_password &amp; salt).</p>
  
  <p>If I try to validate those, it prevents creation:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
      validates :first_name, :last_name, :email, :hashed_pasword, :sal, presence: true
  </code></pre>
  
  <p>This makes sense because they aren't present when the form is submitted.</p>
  
  <p>How do I solve this?</p>
  
  <p><strong>Update</strong>
  In the controller...</p>
  
  <pre><code>  def delete_user
      user = User.find( params[:id] )
      # if !user
      #     flash[:error] = "Problem deleting user"
      #     redirect_to controller:'admin', action:'index'
      # end
      if ( user.update( is_deleted: 1) )
          flash[:notice] = "User successfully deleted"
      else
          flash[:error] = "Problem deleting user"
      end
      redirect_to controller:'admin', action:'index'    
    end
  </code></pre>
  
  <p><strong>Update</strong>
  I'm trying to user the syntax suggested by Sydney below, and here's the error I'm getting. When I use this <code>validates :password, length: { in: 6..20}, on: [:update, :create]</code>, and then "delete" a user, I get this:</p>
  
  <pre><code>/Users/ME/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:393: syntax error, unexpected '[', expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END ...ue &amp;&amp; (validation_context == :[:update, :create]) ... ^ /Users/ESL/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:402: syntax error, unexpected keyword_end, expecting ')' /Users/ESL/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:429: syntax error, unexpected keyword_end, expecting ')' /Users/ESL/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:430: syntax error, unexpected end-of-input, expecting ')'
  </code></pre>