title: Validate tags for an attr_accessor in rails 4
body: <p>I have a project model inside my app where I have:</p>
  
  <pre><code>attr_accessor :tags
  </code></pre>
  
  <p><code>tags</code> is a field coming from the form submitted that gets into the controller for further setup. I want to make sure when the form is submitted the size of this array/tags is not more than 5. how can i do that? I am using rails 4.</p>
  
  <p>This is how the form looks like:</p>
  
  <pre><code>&lt;%=f.autocomplete_field :tags, autocomplete_tags_project_path,'data-delimiter' =&gt; ',', :multiple =&gt; true%&gt;
  </code></pre>
  
  <p><strong>autocomplete_field comes from a gem I am using.</strong></p>
  
  <p>I am unable to use something like this:</p>
  
  <pre><code>validates :tags, :length =&gt; {:maximum =&gt; 5}
  </code></pre>
  
  <p>Any help is appreciated.</p>
  
  <hr>
  
  <p>UPDATE: The form that gets to the controller looks something like</p>
  
  <p><code>"tags"=&gt;["test,
   tets,
   tst,
   test,
   test,
   test,
   tets,
  te st,
   tes"],</code></p>