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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:59:48+00:00 2026-05-11T14:59:48+00:00

I have a URL of form http://www.example.com?foo=one&foo=two I want to get an array of

  • 0

I have a URL of form http://www.example.com?foo=one&foo=two

I want to get an array of values ['one', 'two'] for foo, but params[:foo] only returns the first value.

I know that if I used foo[] instead of foo in the URL, then params[:foo] would give me the desired array.

However, I want to avoid changing the structure of the URL if possible, since its form is provided as a spec to a client application. is there a good way to get all the values without changing the parameter name?

  • 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. 2026-05-11T14:59:49+00:00Added an answer on May 11, 2026 at 2:59 pm

    You can use the default Ruby CGI module to parse the query string in a Rails controller like so:

    params = CGI.parse(request.query_string) 

    This will give you what you want, but note that you won’t get any of Rails other extensions to query string parsing, such as using HashWithIndifferentAccess, so you will have to us String rather than Symbol keys.

    Also, I don’t believe you can set params like that with a single line and overwrite the default rails params contents. Depending on how widespread you want this change, you may need to monkey patch or hack the internals a little bit. However the expeditious thing if you wanted a global change would be to put this in a before filter in application.rb and use a new instance var like @raw_params

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

Sidebar

Related Questions

I have a url in this form http://www.example.com/data/45 . How do I get the
Ok, I have a string of the form string temp = http://www.example.com?file=666111&submitter=Betty&origin=Office&telNo=05555; what I
I have this URL example.com/photo?people I want to rewrite this URL in the form
I have the following script in my javascript... $.ajax({ type: 'POST', url: 'http://www.example.com/ajax', data:
I have urls of the form http://www.site.com/someCompany/someEmployee/name/someName/age/someAge/.../keyN/someValueN/ I am trying to convert them to
I have button which post values of form to url but during post i
I have a Form element: $Form=new Zend_Form; $Form->setAction($this->view->url(array('controller'=>'auth','action'=>'create'),null,true)) ->setMethod('post') ->setAttrib('id','auth-form') ->removeAttrib('enctype'); As can be
see: http://www.eat-drink-etc.com/ I have this code in the header of all the sites' pages:
I have a URL that is being generated using GET variables from a form
I have tried two different implementations for simulating POSTing a form. One uses fsockopen

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.