title: validates_inclusion_of Rails 3 with a query not working as expected
body: <p>I am newish to Rails and i am facing a prblem. I have</p>
  
  <p>Models</p>
  
  <pre><code>Model1
  id: integer
  account_id: integer
  
  Account
  id: integer
  </code></pre>
  
  <p>I have a validation in the Model1 as follows,</p>
  
  <p>Model Code:</p>
  
  <pre><code>validates :account_id, :inclusion =&gt; { :in =&gt; Account.find(:all).collect(&amp;:id)}
  </code></pre>
  
  <p>I use a dropdown for
  View Code:</p>
  
  <pre><code>&lt;%= f.select :account_id, @accounts.collect {|acc| [acc.name, acc.id]}, {:prompt =&gt; 'Select Account' }, { :selected =&gt; @defaultaccount, :class =&gt; 'selectwidth' } %&gt;
  </code></pre>
  
  <p>I am using client side validations to validate the fields before submitting the form. I am using Heroku to deploy my app. </p>
  
  <p>I create an account first and then from the form i try to create a new model1. The drop down is populated with all the accounts that i have. Then i select an account that i created from the dropdown, the client side validations comes into effect and says "is not valid" which is the error message for validates_inclusion_of as if the account never exists. Not sure what ishappening and i checked the database and the account is created which is why the dropdown is loaded with accounts in the first place.</p>
  
  <p>I change the validates_inclusion_of to rails 3 validates :account_id, :inclusion => { :in => {} } syntax and redeploy. Now i try to select that account in the new model1 form, The drop down does not show an error for the account that was previously created. </p>
  
  <p>So then i created a new account and tried to create a new model1 for the new account the validation failure resurfaces.</p>
  
  <p>So its like a cache issue ? Is it a client side validations issue ? I did everything i can to try and find what the issues is but i am out of ideas on what is happening.</p>
  
  <p>So everytime i create an account it expects me redeploy which kills what the application does. How do i get rid of this problem ? Not really sure what is happening. </p>
  
  <p>Config,
  Rails 3
  Deployed in Heroku 
  uses Asset pipeline</p>
  
  <p>Gems:
  Client Side Validations
  Kaminari</p>