Sunday, November 6, 2011

Re: [Rails] Re: functional testing API: GET versus POST?

On Sun, Nov 6, 2011 at 17:24, Grary Stimon <lists@ruby-forum.com> wrote:

>    request = 4_000_000
>    post :loan, {:loan_request=>request, :format => :json}
>
> ...is not formulating the request as JSON?

Correct. This is exactly why you're getting:

> (rdb:1) p request.body.read
> "loan=4000000"

I'm wondering though what happens to the "_request" part. Did you
maybe transcribe by hand and drop it? I am not personally familiar
with generating JSON from Ruby, but it seems to me that the hash above
should generate something like "{ loan_request: 4000000 }". You could
try making *that* string the value of loan_request.

Or maybe something's getting confused with the multiple usage of the
term "request"? Try renaming loan_request to loan_amount and see what
happens.

-Dave

--
LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages.
Where: Northern Virginia, Washington DC (near Orange Line), and remote work.
See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence).
Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson)

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate