Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6340439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:50:10+00:00 2026-05-24T19:50:10+00:00

I was looking over this previous post on using checkboxes to filter results in

  • 0

I was looking over this previous post 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:

User model:

class User < ActiveRecord::Base
  attr_accessor :password, :email
  validates :email, :uniqueness => true, 
                :length => { :within => 5..50 }, 
                :format => { :with => /^[^@][\w.-]+@[\w.-]+[.][a-z]{2,4}$/i }
  validates :password, :confirmation => true,
                   :length => { :within => 4..20 },
                   :presence => true,
                   :if => :password_required?  
  has_one :profile, :dependent => :destroy

Profile model:

class Profile < ActiveRecord::Base
  attr_accessible :field_1, :field_2, :field_3, :field_4...
  belongs_to :user

User controller:

def index
  @user = User.all
end

Index.html.erb:

  <% form_for 'user' do |f| %>
  <table id="Criteria">
    <tr>
      <td class="main head">Fields</td>
      <td></td>
    </tr>
    <tr>
      <td class="head">Field_1:</td>
      <td></td>
    </tr>
    <tr>
      <td class="normal"><%= current_user.profile.field_1 %></td>
      <td><% check_box_tag :field_1 %></td>
    </tr>

If anyone can help explain it I’d appreciate it very much! (And if more info is needed let me know.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:50:11+00:00Added an answer on May 24, 2026 at 7:50 pm

    I guess, you should take a look at Meta Search gem. I used it to solve similar problem here http://omaris.kg/categories/2-zhenskaya-obuv

    UPD

    I have Item model where i defined scopes which filter items according to user request. Below is the scope which filter by brands:

    scope :by_brands, lambda {|brands|
     brands = brands.delete_if {|i| i == "" } if brands.present?
     return if brands.blank?
     composed = self.scoped
    
     composed = composed.where("brand_id IN (?)", brands)
     composed
    }
    

    Then i created class method searchy(search) (didn’t find any better name XD) where i call every scope one after another like self.by_brands(search[:brands]).by_price_range(search[:from], search[:to])...
    search parameter is going to be params[:searchy]

    Then i used like Item.searchy(params[:search]) in my controller. params[:searchy] are got from form_for block in the view.

    That’s it, i guess )

    P.S.: For the first time i wanted to use MetaSearch gem to use its heplers in my form. But i did without it and build my own

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking over the internet for a while about this, but it
Looking over the previous questions and answers it appeared this should work : var
I'm looking over some previous developers code and I come across this line: location.href
I know this is really easy and I'm looking over something but this is
I was looking over this code to calculate math.sqrt in Java. Why did they
I have been looking over this code for the past hour, I cant see
I am looking at nServiceBus and came over this interface namespace NServiceBus { public
This question is related to a previous post of mine Here . Basically, I
I'm looking over some sample code in a cocos2d project. I had previous built
I'm looking over my syllabus for my theoretical computer science class and within the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.