<p>I'm looking at Rails development as a backend to a Flex application and am trying to figure out the communication layer between the Rails app and the Flash Player.  All of the things I am finding suggest using SOAP web services to communicate.</p>

<p>However, Flash supports AMF which is nice and fast (and native).  Is there any way of communicating over AMF from a Rails app, whilst supporting all the "nice" things about AMF (automatic type conversion, data push etc).</p>

[{'answer_id': 70611, 'author': 'Kristian J.', 'author_id': 4588, 'author_profile': 'https://Stackoverflow.com/users/4588', 'pm_score': 0, 'selected': False, 'text': '<p>There\'s a Rails plugin called <a href="http://www.themidnightcoders.com/weborb/rubyonrails/index.htm" rel="nofollow noreferrer">WebORB for Ruby on Rails</a> which uses remoting with AMF.  </p>\n'}, {'answer_id': 70617, 'author': 'DEfusion', 'author_id': 6432, 'author_profile': 'https://Stackoverflow.com/users/6432', 'pm_score': 3, 'selected': True, 'text': '<p>There is <a href="http://www.themidnightcoders.com/weborb/rubyonrails/" rel="nofollow noreferrer">WebORB</a> or <a href="http://code.google.com/p/rubyamf/" rel="nofollow noreferrer">RubyAMF</a> which you can use to respond in AMF from Rails, the approaches are a bit different for each one so it depends on your needs. RubyAMF is discussed in the closing chapters of the <a href="http://www.flexiblerails.com/" rel="nofollow noreferrer">Flexible Rails</a> eBook which is a good resource on using Rails with Flex.</p>\n'}, {'answer_id': 73577, 'author': 'Rollo Tomazzi', 'author_id': 11477, 'author_profile': 'https://Stackoverflow.com/users/11477', 'pm_score': 1, 'selected': False, 'text': "<p>You wouldn't use SOAP web services but rather 'native' REST web services, which are native in Rails. The book quoted by DEFusion above is actually about that: how to use a FLEX client as the front-end of a Rails application using REST (meaning XML).</p>\n\n<p>The AMF protocol has primarily been built by Adobe as a binary protocol to allow FLEX front-ends to talk to CodeFusion and of course Java server applications. It's not free, apart from using Adobe's BlazeDS for which you actually won't have much support. And then of course, you'll have to choose a plugin capable of talking to BlazeDS using the AMF protocol (again, see DEfusion's posts) and rely on it.</p>\n\n<p>You'd be surprised how well direct Flex to Rails via REST works, plus you don't have to rely on third-parties. I'd recommend you try it.</p>\n\n<p>Hope this helps</p>\n"}, {'answer_id': 81508, 'author': 'Glenn', 'author_id': 11814, 'author_profile': 'https://Stackoverflow.com/users/11814', 'pm_score': 2, 'selected': False, 'text': "<p>I'm in the middle of writing a rails/flex application and we're moving to using a JSON communication within the REST framework. Simple HTTP requests from the Flex side handling JSON responses seemed like the best way to decouple the client and server. XML is just as easy. </p>\n\n<p>For what it's worth, we're using the PureMVC framework on the flex side as well, keeping the responses in a client-side model. </p>\n"}, {'answer_id': 152674, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>Go with RubyAMF if you want an MVC style interaction with contollers that can respond to/generate AMF.</p>\n\n<p>Use WebOrb for any other style, including direct access to model objects.</p>\n'}, {'answer_id': 1709178, 'author': 'Kevin Marvin', 'author_id': 207932, 'author_profile': 'https://Stackoverflow.com/users/207932', 'pm_score': 0, 'selected': False, 'text': '<p>You can use WebORB or RubyAMF, or just plain XML - Rails is pretty smart when it comes to XML, with a few gotchas here and there.</p>\n\n<p>We use XML to speak between our Rails apps and our Flex web application, almost exclusively.  It\'s pretty simple.</p>\n\n<p>For retrieving data from your Rails app, just create an HTTPService with result_type of e4x, and call your url.  In your rails controller, do something like:</p>\n\n<pre><code>def people\n  render :xml =&gt; Person.all.to_xml\nend\n</code></pre>\n\n<p>Sometimes, Rails will add the  tag to the end.  If this happens, change your controller to:</p>\n\n<pre><code>def people\n  render :xml =&gt; Person.all.to_xml.target!\nend\n</code></pre>\n\n<p>If you want to send data to your Rails app, it\'s just as easy..</p>\n\n<pre><code>&lt;mx:HTTPService id="theservice" url="http://localhost:3000/svc/add_person" method="POST"&gt;\n &lt;mx:request&gt;\n  &lt;person&gt;\n   &lt;first&gt;Firstname&lt;/first&gt;\n   &lt;last&gt;Lastname&lt;/last&gt;\n  &lt;/person&gt;\n &lt;/request&gt;\n&lt;/HTTPService&gt;\n</code></pre>\n\n<p>and in your controller:</p>\n\n<pre><code>def add_person\n  p=Person.create(params[:person])\n  render :xml =&gt; {:result =&gt; "Success"}.to_xml.target!\nend\n</code></pre>\n\n<ul>\n<li>Kevin</li>\n</ul>\n'}, {'answer_id': 1715030, 'author': 'Mike Summers', 'author_id': 110452, 'author_profile': 'https://Stackoverflow.com/users/110452', 'pm_score': 1, 'selected': False, 'text': "<p>I've built apps using all three methods (WebOrb, RubyAMF, REST)...</p>\n\n<p>WebOrb for Rails is pretty much dead, it hasn't been updated in quite sometime. That said I was able to create a bit of Flex/Ruby magic that makes Flex access to Rails' model objects transparent... if you're interested I'll dig it up and send it to you.</p>\n\n<p>RubyAMF is nice, but not as Flexible (ha!) as WebOrb.</p>\n\n<p>REST returning JSON is a snap, and if I have to build another one of these (I hope not) that's what I'll continue to use.</p>\n\n<p>YMMV.</p>\n"}]
['https://Stackoverflow.com/questions/70524', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4787/']