Frederick Cheung wrote:
> Use the Xor operator ( ^ ) ?
> 
> Fred

Sexy.  Thanks.

I changed above to:

class Dealer < ActiveRecord::Base
  validate :dealer_id?

private
  def dealer_id?
    if !(number.blank? ^ sub_number.blank?)
      errors.add_to_base("You must specify either a Dealer Number OR a 
Sub Dealer Number.")
    end
  end
end

Makes me feel less dirty.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to