I am new to Rails so hopefully not asking stupid questions, but I would appreciate any help on the following: What is the easiest (least hassle) way for my Rails application to accept XML input? I know that I can use WSDL, but is there any default or easily modified way to simply do an HTTP POST of the parameters I want to pass in? Also, I have tried coding a client to do an HTTP POST of what appeared to be the parameters to some simple RAILS applications (like recipe from InstantRails) and it appears that Rails expects a *nested* name-value pair - something my client software can''t currently do. Can someone explain why Rails does this and if there are any work-arounds? -Mark -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060201/114c2de1/attachment.html
Mark Wales wrote:> Also, I have tried coding a client to do an HTTP POST of what appeared > to be the parameters to some simple RAILS applications (like recipe from > InstantRails) and it appears that Rails expects a **nested** name-value > pair ? something my client software can?t currently do. Can someone > explain why Rails does this and if there are any work-arounds?Rails actually does some magic query-key parsing to make that work. As long as you can submit key-value pairs with arbitrary keys, you should be able to get the nested values to work. Something like: http://rails.app/my/query?val[a]=foo&val[b]=bar should give you a params array like: params = {:val =>{:a=>''foo'', :b=>''bar''}} I don''t know if that''s enough to get your client to work, though... -- Alex
I just wanted to clarify what you are suggesting. If I want to attain
this:
Parameters: {"commit"=>"Create",
"category"=>{"name"=>"Test"},...
I should insert the following pairs of Strings:
"commit", "Create"
"category[name]", "Test"
Is this what you had in mind?
-Mark
-----Original Message-----
From: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Alex Young
Sent: Wednesday, February 01, 2006 8:38 AM
To: rails@lists.rubyonrails.org
Subject: Re: [Rails] HTTP POST of XML
Mark Wales wrote:> Also, I have tried coding a client to do an HTTP POST of what appeared
> to be the parameters to some simple RAILS applications (like recipe
from > InstantRails) and it appears that Rails expects a **nested**
name-value > pair - something my client software can''t currently do. Can
someone
> explain why Rails does this and if there are any work-arounds?
Rails actually does some magic query-key parsing to make that work. As
long as you can submit key-value pairs with arbitrary keys, you should
be able to get the nested values to work. Something like:
http://rails.app/my/query?val[a]=foo&val[b]=bar
should give you a params array like:
params = {:val =>{:a=>''foo'',
:b=>''bar''}}
I don''t know if that''s enough to get your client to work,
though...
--
Alex
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
Mark Wales wrote:> I just wanted to clarify what you are suggesting. If I want to attain > this: > > Parameters: {"commit"=>"Create", > "category"=>{"name"=>"Test"},... > > I should insert the following pairs of Strings: > > "commit", "Create" > "category[name]", "Test" > > Is this what you had in mind?Without being precisely sure what you''re inserting to, that looks about right, yes. -- Alex