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

  • Home
  • SEARCH
  • 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 6073563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:17:05+00:00 2026-05-23T10:17:05+00:00

Rails 3 question. If i send a request like this PUT http://myapp/posts/123?post [title]=hello then

  • 0

Rails 3 question.

If i send a request like this PUT http://myapp/posts/123?post[title]=hello

then in my controller i get params = {:id => 123, :post => {:title => "hello"}}

This is fine normally and usually useful for eg Post.create(params[:post])

However, on this occasion i need to get access to the ‘raw’ form of the params so i can order them pull out the values, dealing with them all as simple strings, ie i want them listed so the param name is "post[title]" and the param value is "hello".

Is there any way i get get these values? I thought there might be a method of request that has the params in their original stringy form but i can’t find one.

It had occurred to me to try to convert the hash back into a string with to_param but this seems a but dirty and possibly unecessary.

As a bonus, i’d like it to ignore the :id parameter, literally just taking the part after the ? in the original request. In fact, if i can just get back the original request string, ie "http://myapp/posts/123?post[title]=hello" then that would do: i could split on the ? and take it from there. It just occurred to me that i can probably get it out of a header. In the meantime though, if anyone knows a nicer way then tell me please 🙂

Grateful for any advice – max

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

    Don’t do the parsing by hand, please. Grab the URI from the Rails request:

    url = request.url
    # Or, depending on the Rails version and stack
    url = request.request_uri
    # Or even
    url = request.scheme + '://' + request.host_with_port + request.fullpath
    

    The return value from request.url seems to depend on your server stack, request.request_uri is supposed to fix that but doesn’t seem to exist in Rails 3.1. The third “build it all yourself” approach should produce consistent results everywhere. Sigh.

    Then, once you have the URI, use URI.parse and URI.decode_www_form to parse it:

    u = URI.parse(url)
    q = URI.decode_www_form(u.query)
    # if u.query was "a=b&c=d&a=x" then q is
    # [["a", "b"], ["c", "d"], ["a", "x"]]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is one more newbie question: require 'tasks/rails' I saw this line in Rakefile
Sorry, if this is a noobish question, but I'm just getting started with Rails
This question is related to this other question: Change rails text_field form builder type
Another basic Rails question: I have a database table that needs to contain references
I've got a really simple rails question here but I can't seem to find
The question says it all. I can't seem to find any recent rails tutorials
I'm learning Rails and it's going well so far. My biggest question at the
Sorry for the slightly noobish question, as I am writing my first rails app.
I have a Rails app that will post some data to another Rails app.
This is probably a really dumb question with a simple answer but... I am

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.