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 6730649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:26:01+00:00 2026-05-26T10:26:01+00:00

I need to implement some search functionality within a Rails application. Most of the

  • 0

I need to implement some search functionality within a Rails application. Most of the stuff I have found is generally aimed at simple plain-text search. I am trying to implement something much more specific. The sort of functionality I am looking to create is this (from a C application):

http://andyc.ac/query.gif

The form just submits the data entered by the user. So I need to translate strings like “3..7” into SQL conditions for the where method e.g.

TestLine.where( "test_int >= ? and test_int <= ?", MinInt, MaxInt )

It seems like this is something that already exists somewhere. The exact format expected is not too important, as the users are not shared between the Rails and C applications. How would this be done?

  • 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-26T10:26:02+00:00Added an answer on May 26, 2026 at 10:26 am

    FWIW the specific functionality you describe is actually supported directly. Well.. almost. From the docs:

    A range may be used in the hash to use the SQL BETWEEN operator:

    Student.where(:grade => 9..12)
    

    Of course then it’s a matter of translating the user’s string input to a Range, which isn’t very complex, e.g.:

    def str_to_range str
      str =~ /(\d+)\.\.(\d+)/
    
      Range.new *$~.captures.map(&:to_i)
    end
    

    It would probably make the most sense in a scope on your model. (Of course a shortcut would be to simply eval '9..12' but evaling input from the end user is a really, really bad idea.)

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

Sidebar

Related Questions

I need to implement some kind of metric space search in Postgres(*) (PL or
I need to implement some form of communication mechanism in my application, to send
To implement data access code in our application we need some framework to wrap
I need to implement a search engine. So I have a dictionary which is
I need to provide some kind of global search over most of the data
I need some help. Right now i have done a file search that will
I need to implement a Search box on a C# MVC application that I'm
I need to implement some search functionalities in my app and want to use
Hey, i'm extending some WPF controls, and need to implement some custom events. I've
I need to implement something. Something that could do some certain task in my

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.