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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:13:00+00:00 2026-06-02T07:13:00+00:00

I have developed a small API that returns some minor JSON objects (mainly small

  • 0

I have developed a small API that returns some minor JSON objects (mainly small resources, nothing fancy), but I am in a situation where I need to expand one of the API endpoints to return a little more than just whats there currently.

For Example – Currently, I have the following in my routes:

resources :school_types do
        resources :schools
      end

So, if a user accesses /api/v1/school_types/1/schools.json an entire listing of schools will come back based on the school_type_id

Well, I am now wanting to take it a little further and do the following:
/api/v1/school_types/1/schools.json?param_1=foo&param_2=bar

So when I construct the ActiveRecord call it would dynamically generate the SQL query based on the parameters passed in.

This is what I have so far:

conditions = ""
      params.except(:controller, :format, :action).each_with_index do |value, index|
        conditions << "#{params[index]} = #{value} AND "
      end 

This is the conditions variable output: " = [\"state_id\", \"1\"] AND = [\"district_id\", \"1\"] AND = [\"school_type_id\", \"1\"] AND "

Obviously I am doing something wrong, LOL.

  • 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-06-02T07:13:03+00:00Added an answer on June 2, 2026 at 7:13 am

    I would strongly suggest using a tool like MetaSearch rather than rolling your own. Your current implementation is highly subject to SQL injection attacks.

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

Sidebar

Related Questions

i have developed a small application and was working fine on developing machine but
I have developed a small view that contains special char like 'é' and when
Hey guys, I have developed a small site that i would like to embed
I have developed a small iPhone application by using singleton that I use to
I have developed a small application that I would like to try and sell
I have developed a small server that recives connections (using basically the example here:
I have developed a small ASP.NET MVC 3 application in that I have an
I have developed a small application and now i want to protect it. I
We have developed a small web application for a client. We decided on the
I have developed a small download system in PHP, where files are downloaded through

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.