SubReview image

User Login


Or OpenID




Register

Bookmark and Share SubReview
Add the SubReview review Feed

At some point when creating a Flex application you will want to update an item in the database using Rails(e.g. the details about a film).

To update a resource using REST you need to use the HTTP verb PUT, so the code below should work if we’re updating a film with ID=1:


<mx:HTTPService  id="UpdateFilm" 
           method="PUT"         
           url="films/1.xml" 
           useProxy="false" 
      ...
    </mx:HTTPService>


Unfortunately the above code doesn’t work, if you look in the rails logs you’ll find it’s doing a POST. HTTPService supports GET|POST|PUT|DELETE, but only if the useProxy is set to true (which means your using a Flex Data Services).

The manual states if useProxy=”false” you can only use GET or POST. Not particularly good if you want to get some rest in:-)

Luckily Rails has a work around for this, which is the detection of a _method parameter on the end of a URL. For example:



<mx:HTTPService  id="UpdateFilm" 
         method="POST"          
         url="films/1.xml?_method=PUT
         ....
</mx:HTTPService>

Posted in Category::Ruby on Rails & Flex by sub1  19 Mar 08

You must log in to comment on this article


SubReview was developed using Ruby on Rails v2, Flex and Yahoo YUI.

The software design behind the scenes is roughly based on a REST based architecture. If you’ve never heard of REST before then this site has a good explanation about it.

Some of the REST resources on this site are:

assets
articles
reviews

Posted in Category::Ruby on Rails & Flex by sub1  17 Mar 08

You must log in to comment on this article



Articles

Latest Film reviews
Daisy (데이지) 
Casshern (キャシャーン) 
SPL, Sha Po Lang (殺破狼) 
Sky Blue (원더풀 데이즈) 
R-Point (알 포인트) 
Latest Gadget reviews
Powerbar 
Philips Sonicare B400 Series (HX6431/46) 
FlashSticks 
Nokia N76 
Sony W880i 
Latest Game reviews
F1 2009 (Wii) (F1 2009) 
Resident Evil 4 (Wii Version) 
Latest Articles
OpenID now enabled by sub1  (06/05)
Why is GTA IV not on the Wii? by nicos  (12/04)
Capistrano Nginx Mongrel VHost by sub1  (04/04)
Flex HTTPService PUT method problem by sub1  (19/03)
SubReview development by sub1  (17/03)
Welcome by sub1  (11/03)


Bruce Lee Legendary Collection (Blu-ray) (Hong Kong Version)