MarkUs Blog

MarkUs Developers Blog About Their Project

Prototype/Ajax.Request -> Rails – The Plot Thickens Part 2

with one comment

Still no solution in sight.  I’ve tried creating a brand new Rails project, and the behaviour persists there as well.  I’m convinced it’s a problem with Rails though, and not a problem in my machine.

Let’s go over the facts again:

  • I have Rails 2.1.0 installed on an Ubuntu 8.04 Hardy Heron Tablet PC
  • I’m using a Postgres database on the OLM project
  • Using Prototype JS library V 1.6.0.1
  • We’re using Mongrel, not WeBRICK
  • Using Ajax.Request with the ‘POST’ method does not pass any parameters to the params hash in the target controller
  • It works with GET though!
  • When using POST, I can see the parameters if I inspect the request object – they’re in @parameters, which I cannot seem to access
  • POSTing seems to work on other computers, using the same OLM code checked out from the repository
  • I’ve tried a complete reinstall of Rails, with the same result

Maybe my uninstall assumption is wrong:  what’s the best way to completely purge Rails from my machine?  I essentially followed these steps before:

Thoughts from anybody?

Thanks,

-Mike

Written by m_conley

November 21st, 2008 at 3:04 am

Posted in Uncategorized

One Response to 'Prototype/Ajax.Request -> Rails – The Plot Thickens Part 2'

Subscribe to comments with RSS or TrackBack to 'Prototype/Ajax.Request -> Rails – The Plot Thickens Part 2'.

  1. Are you both using the same browser? What is the CONTENT_TYPE of the POST?

    This seems suspect to me:

    rails/actionpack/lib/action_controller/base.rb:287

    # Modern REST web services often need to submit complex data to the web application.
    # The @@param_parsers hash lets you register handlers which will process the HTTP body and add parameters to the
    # params hash. These handlers are invoked for POST and PUT requests.
    #
    # By default application/xml is enabled. A XmlSimple class with the same param name as the root will be instantiated
    # in the params. This allows XML requests to mask themselves as regular form submissions, so you can have one
    # action serve both regular forms and web service requests.
    #
    # Example of doing your own parser for a custom content type:
    #
    # ActionController::Base.param_parsers[Mime::Type.lookup(‘application/atom+xml’)] = Proc.new do |data|
    # node = REXML::Document.new(post)
    # { node.root.name => node.root }
    # end
    #
    # Note: Up until release 1.1 of Rails, Action Controller would default to using XmlSimple configured to discard the
    # root node for such requests. The new default is to keep the root, such that “David” results
    # in params[:r][:name] for “David” instead of params[:name]. To get the old behavior, you can
    # re-register XmlSimple as application/xml handler ike this:
    #
    # ActionController::Base.param_parsers[Mime::XML] =
    # Proc.new { |data| XmlSimple.xml_in(data, ‘ForceArray’ => false) }
    #
    # A YAML parser is also available and can be turned on with:
    #
    # ActionController::Base.param_parsers[Mime::YAML] = :yaml

    That’s the first thing that looked promising after I acked for “params” in the rails source. Other than that, where’s your debugger?

    Jeff Balogh

    21 Nov 08 at 6:54 pm

Leave a Reply