Getting parameters from the request object

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

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

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. [email protected]

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

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:incollapse’
/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:inxml_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