title: How to apply tags with acts_as_taggable_on using check boxes?
body: <p>I would like to assign two different "types" of tags (sector categories and free tagging) to a Company model using <a href="http://github.com/mbleigh/acts-as-taggable-on" rel="nofollow noreferrer">acts_as_taggable_on</a>. NB: I'm new to RoR!</p>
  
  <p>This is easy to do if just using standard text input fields, but I would like to use check-boxes on one type (a fixed sector category tag that is predefined), and then allow the user to add comma separated tags in an input field. </p>
  
  <p>I have played around with this problem in various ways,... one inspired by <a href="https://stackoverflow.com/questions/2082399/thinking-sphinx-and-acts-as-taggable-on-plugin">this question</a>...but I cannot get it to work</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code># models/company.rb
  class Company ...
    acts_as_taggable_on :tags, :sectors
  
    has_many :taggings,
             :as =&gt; :taggable,
             :include =&gt; :tag,
             :class_name =&gt; "ActsAsTaggableOn::Tagging",
             :conditions =&gt; { :taggable_type =&gt; "Company" }
  
    has_many :sector_tags, 
             :through =&gt; :taggings, 
             :source =&gt; :tag,
             :class_name =&gt; "ActsAsTaggableOn::Tag",
             :conditions =&gt; {:context =&gt; "sectors"}
  end
  </code></pre>
  
  <p>in the form (using simple_form gem) I have...</p>
  
  <pre><code># views/companies/_form.html.haml
  = simple_form_for @company do |f|
    = f.input :name
    = f.association :sector_tags, :as =&gt; :check_boxes, :hint =&gt; "Please click all that apply"
    = f.input :tag_list
    = f.button :submit, "Add company"
  </code></pre>
  
  <p>And in my Company controller I have</p>
  
  <pre><code># controllers/companies_controller.rb
  def create
    @company = current_user.companies.build(params[:company])
    if @company.save
    ...
  end
  </code></pre>
  
  <p>But this causes a validation error: </p>
  
  <pre><code>ActiveRecord::RecordInvalid in CompaniesController#create
  Validation failed: Context can't be blank
  </code></pre>
  
  <p>Can anyone hint at how I can do this right? </p>
  
  <p>A related question is if this is a good way to do it at all? Would I be better off just using a Category model for assigning sector tags through a joint model?</p>
  
  <p>Thanks!</p>