Ruby on Rails, is it possible to make the model validation dependent on the input? <p>In my project I have two models, <code>Treatment</code> and <code>Category</code>:</p> <pre><code> class Category &lt; ActiveRecord::Base attr_accessible :typ has_many :treatments end class Treatment &lt; ActiveRecord::Base belongs_to :patient belongs_to :category attr_accessible :content, :day, :typ, :category_typ end </code></pre> <p>So in my treatment form the user can also choose the category (around 4 categories):</p> <pre><code>&lt;div class="field"&gt; &lt;%= f.label :category_id %&gt;&lt;br /&gt; &lt;%= f.collection_select :category_id, Category.find(:all), :id, :typ %&gt; &lt;/div&gt; </code></pre> <p>So my question is, can I make the validation of the <code>Treatment</code> model dependent on the selected categories in the form? And how?</p>