title: Adding an error message to a custom validator
body: <p>I have a custom validator and I am trying to output an error message when it fails but have been unable to do so. Could someone please tell me if I am doing this in the correct place.</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    self.table_name = "user"
  
    attr_accessible :name, :ip, :printer_port, :scanner_port
  
    validates :name,        :presence =&gt; true,
                            :length =&gt; { :maximum =&gt; 75 },
                            :uniqueness =&gt; true                          
  
    validates :ip,          :length =&gt; { :maximum =&gt; 75 },
                            :allow_nil =&gt; true     
  
    validates :printer_port, :presence =&gt; true, :if =&gt; :has_association? 
  
    validates :scanner_port, :presence =&gt; true, :if =&gt; :has_association?          
  
    def has_association?
      ip != nil
    end
  end
  </code></pre>
  
  <p>I had it as follows:</p>
  
  <pre><code>validates :printer_port, :presence =&gt; true, :message =&gt; "can't be blank", :if =&gt; :has_wfm_association?
  </code></pre>
  
  <p>But was receiving an error</p>
  
  <pre><code>Unknown validator: 'MessageValidator'
  </code></pre>
  
  <p>And when I tried to put the message at the end of the validator the comma seperating the has_association? turned the question mark and comma orange</p>