title: Rails 3: Multiple Select with has_many through associations
body: <p>I want to get possibility to select several Categories for one Post with multiple select.</p>
  
  <p>I have next models: Post, Category and PostCategory.</p>
  
  <pre><code>class Post &lt; ActiveRecord::Base
    has_many :post_categories
    has_many :categories, :through =&gt; :post_categories
  end
  
  class Category &lt; ActiveRecord::Base
    has_many :post_categories
    has_many :posts, :through =&gt; :post_categories
  end
  
  class PostCategory &lt; ActiveRecord::Base
    has_one    :post
    has_one    :category
    belongs_to :post      # foreign key - post_id
    belongs_to :category  # foreign key - category_id
  end
  </code></pre>
  
  <p>In my controller I have something like @post = Post.new .
  I've created some categories.</p>
  
  <p>And in view I have:</p>
  
  <pre><code>&lt;%= form_for @post do |f| %&gt;
      &lt;%= f.text_field :title %&gt;
      &lt;%= f.select :categories, :multiple =&gt; true %&gt;
      &lt;%= f.submit %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>And... where is my categories? I have only "multiple" in select options. I think it's something wrong with my form.</p>