# Getting parameters from the request object

**URL:** <https://www.ruby-forum.com/t/getting-parameters-from-the-request-object/145596>\
**Category:** Rails\
**Created:** [August 11, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/getting-parameters-from-the-request-object/145596 "2008-08-11T23:08:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fernando](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/779978/32.png) [@fernando](https://www.ruby-forum.com/u/fernando)\
**Post date:** [August 11, 2008, 11:08pm UTC](https://www.ruby-forum.com/t/getting-parameters-from-the-request-object/145596/1 "2008-08-11T23:08:27Z")

</div>

Hi guy’s,

I am having trouble getting parameters back from a POST request. I am  
using GWT on the front end so I do not have any params[:name].

request.raw\_post

returns:

name=hello&date=12&month=07&year=2008&administrator=brewer

I want to separate this into the variables name, date, month, year,  
and administrator but I do not know how to do this in Rails. Is there  
an easy way?

Any help would be much appreciated.

Tim

---

<div class="post-metadata">

**Author:** ![fernando](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/779978/32.png) [@fernando](https://www.ruby-forum.com/u/fernando)\
**Post date:** [August 11, 2008, 11:12pm UTC](https://www.ruby-forum.com/t/getting-parameters-from-the-request-object/145596/2 "2008-08-11T23:12:33Z")

</div>

On 11 Aug 2008, at 22:08, fernando wrote:

> name=hello&date=12&month=07&year=2008&administrator=brewer
> 
> I want to separate this into the variables name, date, month, year,  
> and administrator but I do not know how to do this in Rails. Is there  
> an easy way?

That’s odd, as that’s just the same data that a form would submit. Is  
GWT submitting it with a funny mime type?  
You can configure parameter parsers on a per MIME type basis via the  
ActionController::Base.param\_parsers hash

Fred

---

<div class="post-metadata">

**Author:** ![fernando](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/779978/32.png) [@fernando](https://www.ruby-forum.com/u/fernando)\
**Post date:** [August 11, 2008, 11:19pm UTC](https://www.ruby-forum.com/t/getting-parameters-from-the-request-object/145596/3 "2008-08-11T23:19:00Z")

</div>

The MIME type is text/plain by default in GWT but you can set it too  
whatever.

What is it normally set to in a rails form?

On Aug 11, 10:11 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![fernando](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/779978/32.png) [@fernando](https://www.ruby-forum.com/u/fernando)\
**Post date:** [August 13, 2008, 6:43pm UTC](https://www.ruby-forum.com/t/getting-parameters-from-the-request-object/145596/4 "2008-08-13T18:43:08Z")

</div>

On 13 Aug 2008, at 15:59, fernando wrote:

> OK so I changed the Content-Type to “application/x-www-form-  
> urlencoded”
> 
> and in Mongrel the parameters passed look like this:  
> Parameters: {“name”=\>“hello date=12 month=07 year=2008  
> administrator=brewer”, “action”=\>“createEvent”,  
> “controller”=\>“calendar”}

That’s odd. Have you checked (eg with tcpdump or similar or sticking a  
breakpoint in the rails parameter thingy before it has parsed the  
parameters) exactly what bytes your mongrel is receiving ?

Fred

---

<div class="post-metadata">

**Author:** ![fernando](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/779978/32.png) [@fernando](https://www.ruby-forum.com/u/fernando)\
**Post date:** [August 13, 2008, 5:00pm UTC](https://www.ruby-forum.com/t/getting-parameters-from-the-request-object/145596/5 "2008-08-13T17:00:26Z")

</div>

OK so I changed the Content-Type to “application/x-www-form-  
urlencoded”

and in Mongrel the parameters passed look like this:  
Parameters: {“name”=\>“hello date=12 month=07 year=2008  
administrator=brewer”, “action”=\>“createEvent”,  
“controller”=\>“calendar”}

i.e. Rails has only identified the first parameter and has assigned  
everything else to it. Whats going on?

Incidentally if I set the Content-Type to either text/plain, text/xml  
or application/xml Rails gives me a:

Status: 500 Internal Server Error  
You have a nil object when you didn’t expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.attributes  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/  
vendor/xml-simple-1.0.11/xmlsimple.rb:708:in `get_attributes' /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/ vendor/xml-simple-1.0.11/xmlsimple.rb:462:in`collapse’  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/  
core\_ext/hash/conversions.rb:13:in `xml_in_string' /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/ core_ext/hash/conversions.rb:23:in`xml\_in\_string’  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active\_support/  
core\_ext/hash/conversions.rb:171:in `from\_xml’

Any help here would be very much appreciated.

Tim
