title: Filter users by using checkboxes for profile data in Rails
body: <p>I was looking over this <a href="https://stackoverflow.com/questions/4869679/using-checkboxes-to-filter-records">previous post</a> on using checkboxes to filter results in Rails but got kinda lost. I'm new to programming but want to filter Users on my index page depending on what profile data is checked in a sidebar. Ideally, the index page would start out with all Users, then filter down depending on the checkboxes. Here's relevant info from my User and Profile models, User controller, and the index.html.erb file:</p>
  
  <p>User model:</p>
  
  <pre><code>class User &lt; ActiveRecord::Base
    attr_accessor :password, :email
    validates :email, :uniqueness =&gt; true, 
                  :length =&gt; { :within =&gt; 5..50 }, 
                  :format =&gt; { :with =&gt; /^[^@][\w.-]+@[\w.-]+[.][a-z]{2,4}$/i }
    validates :password, :confirmation =&gt; true,
                     :length =&gt; { :within =&gt; 4..20 },
                     :presence =&gt; true,
                     :if =&gt; :password_required?  
    has_one :profile, :dependent =&gt; :destroy
  </code></pre>
  
  <p>Profile model:</p>
  
  <pre><code>class Profile &lt; ActiveRecord::Base
    attr_accessible :field_1, :field_2, :field_3, :field_4...
    belongs_to :user
  </code></pre>
  
  <p>User controller:</p>
  
  <pre><code>def index
    @user = User.all
  end
  </code></pre>
  
  <p>Index.html.erb:</p>
  
  <pre><code>  &lt;% form_for 'user' do |f| %&gt;
    &lt;table id="Criteria"&gt;
      &lt;tr&gt;
        &lt;td class="main head"&gt;Fields&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td class="head"&gt;Field_1:&lt;/td&gt;
        &lt;td&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td class="normal"&gt;&lt;%= current_user.profile.field_1 %&gt;&lt;/td&gt;
        &lt;td&gt;&lt;% check_box_tag :field_1 %&gt;&lt;/td&gt;
      &lt;/tr&gt;
  </code></pre>
  
  <p>If anyone can help explain it I'd appreciate it very much! (And if more info is needed let me know.)</p>