How to get a POST data from in controller?

Hi, I am newbie in Ruby.
Here is the situation I meet:
I got a javascript app that will send string data by using HTTP POST
method to another ruby app.
Here is the url: http://localhost:3000/home/receive_data
So, the ruby app got a home controller and receive_data action to
handle it.
It will write log when receive_data action works just like the
following code does:

  def receive_data
    trace "receive_data..."
    render :text => "ok"

But I never see logs appear when the javascript app send data.
If I change the HTTP method of javascript app while sending data to
GET, then it will get logs.
It means the action in controller only can handle a request of GET
How should I do, if I wanna receive data from POST method?



normally Rails takes care of this automagically, and it doesn't matter
to an action whether the data comes in as GET or POST - in both cases,
the data is accessible through the params method.

If you're not getting anything in the logs, I would try to locate the
problem rather within the calling javascript than within the rails
app. If all else fails, have you tried POSTing to the action manually,
via wget or with a hand-built HTML form?

Out of sheer interest, what's 'trace'? Sorry if this is an obvious
question, but I am slightly hungover at the moment .. :slight_smile:


Sorry! I forget to explain the trace function. In fact, it works just
like "puts" with a additional timestamp log at head. Here it is:

  def trace(str = '')
    p "[""] ***** "+str.to_s

And I forget to say, it is a AJAX POST request from the javascript
When I test it again today, it shows up the error like below (I didn't
alert it before):
ActionController::InvalidAuthenticityToken in

After known what the error it is, I already found the solution in this
I override the verifiable_request_format? method in controller, then
the receive_data action works just as I expected.
Thank for yor help any way! :slight_smile: