Suppose I am entering validation code into my model of multi-language publication database. The database needs either an English or a Japanese title for a particular journal. So I need to validate_presence_of at least one of the two. Right now I can easily check that both exists, but am stumped on the case of ‘at least one’:
class Article < ActiveRecord::Base belongs_to :publication validate_presence_of :journal_title validate_presence_of :journal_title_ja end
I think this might require a statement like:
:if => :jornal_title_ja is nil
This should work. Hope I got the question straight.
Watch the episode no. 41 on railscasts for better understanding