title: Rails 3 - Custom Validation
body: <p>I'm somewhat confused by my options for custom validations in Rails 3, and i'm hoping that someone can point me in the direction of a resource that can help with my current issue.</p>
  
  <p>I currently have 3 models, <code>vehicle</code>, <code>trim</code> and <code>model_year</code>. They look as follows:
  <code><pre>class Vehicle &lt; ActiveRecord::Base
    attr_accessible :make_id, :model_id, :trim_id, :model_year_id
    belongs_to :trim
    belongs_to :model_year
  end</p>
  
  <p>class ModelYear &lt; ActiveRecord::Base
    attr_accessible :value
    has_many :model_year_trims
    has_many :trims, :through => :model_year_trims
  end</p>
  
  <p>class Trim &lt; ActiveRecord::Base
    attr_accessible :value, :model_id
    has_many :vehicles
    has_many :model_year_trims
    has_many :model_years, :through => :model_year_trims
  end
  </pre></code></p>
  
  <p>My query is this - when I am creating a vehicle, how can I ensure that the model_year that is selected is valid for the trim (and vice versa)?</p>