Rails 1.2 doesn't send POST parameters

I have a strange problem with my Rails app that I haven’t seen anyone
else mention.

I upgraded to rails 1.2 today (1.2.3 actually, and yes, I’ve been
putting it off). When I did so all of my controllers that accept a
POST method lost their paraameters. The param hash is empty when those
controllers get called, and they can’t access any of the form
parameters. Controllers that are called via GET still work fine.

I reverted back to 1.1.6 and everything is fine. What could be causing
this?

On Apr 18, 2007, at 8:12 PM, Michael Meckler wrote:

I upgraded to rails 1.2 today (1.2.3 actually, and yes, I’ve been
putting it off). When I did so all of my controllers that accept a
POST method lost their paraameters. The param hash is empty when those
controllers get called, and they can’t access any of the form
parameters. Controllers that are called via GET still work fine.

I don’t really know whether the lack of this step can have that
consequence, but just in case, did you run rails:update in the root
of your application after the upgrade of Rails itself?

– fxn

Hi, there are two actions that should take place after performing ‘gem
update rails’:

a) update environment.rb so that it uses 1.2.3

b) execute ‘rake rails:update’ in the root directory of your rails
application

-Conrad

My config/environment.rb has the line:

RAILS_GEM_VERSION = ‘1.2.3’

and I ran rake rails:update, which just seemed to change some of the
javascript files and add a process/inspect script.

I do seem to be running the latest rails, it’s just that my
controllers don’t seem to get passed parameters from POST calls. They
don’t even show up in the log. But if I switch back to Rails 1.1.6
then everything is fine.

I found someone else who has this same problem. His solution was to
add this method in the application controller:

def parse_post_params
request.raw_post().split(’&’).each do |raw_param|
raw_param_split = raw_param.split(’=’)
params[raw_param_split[0]] = raw_param_split[1]
end
end

and then call parse_post_params in every method of every controller.

This does seem to work for me, at least, in the methods I added it to.
But it seems a horrible violation of DRY. So I’m looking for a better
solution.

Hi, how are you getting to the controller/action (i.e. what are you
doing to
invoke the action… ) ? Please post your controller code and/or
relevant
views.

-Conrad

I think I found the problem.

The forms were being submitted not from a browser, but from an
external server which was just sending HTTP at my Rails app. There
wasn’t any view involved at all.

The HTTP_MIMETYPE header wasn’t set to anything. This didn’t seem to
bother Rails 1.1.6, but with Rails 1.2.x it seems to ignore the POST
block if this is not set to “application/x-www-form-urlencoded”

When I made sure that header was set properly in the sending server,
then my Rails app got all the params passed through properly.