<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flash Remoting for Ruby on Rails &#187; Remoting</title>
	<atom:link href="http://blog.rubyamf.org/category/remoting/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rubyamf.org</link>
	<description>Ruby AMF - Flash Remoting for Ruby on Rails</description>
	<lastBuildDate>Tue, 25 Aug 2009 12:23:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SSR 2 Breakdown</title>
		<link>http://blog.rubyamf.org/2008/01/28/ssr-2-breakdown/</link>
		<comments>http://blog.rubyamf.org/2008/01/28/ssr-2-breakdown/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 04:36:47 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[AMF]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[SSR]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=103</guid>
		<description><![CDATA[John Farrar had asked about SSR 2 &#8211; more information on SSR and what benefits / things you get with it. I thought I&#8217;d be a little more specific and outline what it is and what you get. Bare with me if I start out by pointing out the obvious.
So, I guess here&#8217;s the obvious. [...]]]></description>
			<content:encoded><![CDATA[<p>John Farrar had asked about SSR 2 &#8211; more information on SSR and what benefits / things you get with it. I thought I&#8217;d be a little more specific and outline what it is and what you get. Bare with me if I start out by pointing out the obvious.</p>
<p>So, I guess here&#8217;s the obvious. SSR is a small AS3 remoting library. Stands for &#8220;Super Simple Remoting&#8221; because it&#8217;s simple. My goal when writing it was to make one library that works in Flash and Flex and handle logic that should be in every application. Personally I like using this in both Flash and Flex because I don&#8217;t forget how to use it. I always forget how to use RemoteObject so this makes a standard library for either.</p>
<p>So here&#8217;s an example of a bare minimum setup of SSR to make a remoting call.</p>
<pre>
import com.niarbtfel.remoting.RemotingConnection;
import com.niarbtfel.remoting.RemotingService;
import com.niarbtfel.remoting.events.FaultEvent;
import com.niarbtfel.remoting.events.ResultEvent;

var rc:RemotingConnection = new RemotingConnection("http://localhost/myGateway",3);
//gateway
//3 is the amf format

var rs:RemotingService = new RemotingService(rc,"MyService",4000,3,true);
//rc is the remoting connection to use for this service
//"MyService" is the service target on the server.
//4000 is the amount of time a call waits before retrying the call.
//3 is the amount of retries to attempt per call.
//true turns on call limiting, which means that the same exact call can't be made while one is waiting for a response or timeout.

//callbacks for calls, keep reading.
function onr(re:ResultEvent):void{}
function onf(fe:FaultEvent):void{}

//callbacks for calls, keep reading.
function onrArgs(re:ResultEvent,args:Array):void{}
function onfArgs(fe:FaultEvent,args:Array):void{}

rs.myMethod([],onr,onf,false); //make a call
//[] = call arguments
//onr is the result callback
//onf is the fault callback
//false - don't return the original arguments sent in the request to the callback functions

var mym:String = "myMethod";
rs.apply(mym,[],onrArgs,onfArgs,true); //make a call
//[] = call arguments
//onr is the result callback
//onf is fault callback
//true - return the original arguments sent in the request to the callback functions
</pre>
<p>This is the simplest form of setting up flash remoting with SSR without any event listeners on the RemotingConnection or RemotingService. Events for RemotingConnection and RemotingService are documented in the class files. You get events for things like disconnects, retries, timeouts, etc.</p>
<p>Each RemotingService can have a timeout specified for each call going to that service, as well as a maximum attempts allowed per call. If one call is made, but doesn&#8217;t receive a response within the timeout specified, it&#8217;s tried again. This happens over and over until the maximum attempts is reached, and a timeout event is dispatched.</p>
<p>RemotingService has an option to turn on call limiting. Which makes the remoting service smart about what to call and what not to call. If you made a call to &#8220;MyService.myMethod&#8221; with parameters ["something","something else"], it would not let you make that same call until the first one has completed, or has timed out. You&#8217;d still be able to make calls to any other service method.</p>
<p>Another new feature is caching. Say you make calls to some service numerous times, but the data is always the same. Instead of doing that you can enable the service to use caching. Here&#8217;s a snippet from above with caching in place:</p>
<pre>
var rs:RemotingService = new RemotingService(rc,"MyService",4000,1,true);
rs.remotingCache = new RemotingCache(-1);
//-1 specifies that the cache should never expire. (supply a time in milliseconds for an expiration if needed)
</pre>
<p>Now every call made through this remoting service will be cached. If the exact same call is made, the results are pulled from cache instead.</p>
<p>SSR also has paging built in with a RemotingPager. Here&#8217;s a snippet on how that works:</p>
<pre>
import com.niarbtfel.remoting.RemotingConnection;
import com.niarbtfel.remoting.RemotingService;
import com.niarbtfel.remoting.events.FaultEvent;
import com.niarbtfel.remoting.events.ResultEvent;
import com.niarbtfel.remoting.paging.RemotingPager;
import com.niarbtfel.remoting.paging.PageResponder;

var rc:RemotingConnection = new RemotingConnection("http://localhost/myGateway",3);
var rs:RemotingService = new RemotingService(rc,"MyService",4000,3,true);
var rp:RemotingPager;
var pr:PageResponder // just to include in compilation

var totalRecordsOnServer:int = 400; //should come from server instead.

//callbacks for calls, keep reading.
function onrArgs(re:ResultEvent,args:Array):void
{
  rp = new RemotingPager(rs,"myMethod",PageResponder,["someParameter"],re.result as Array,totalRecordsOnServer,50,2,1);
  myButton.addEventListener(MouseEvent.CLICK, onbc);
}
function onfArgs(fe:FaultEvent,args:Array):void{}

function onbc(me:MouseEvent):void
{
   if(rp.hasNext())
   {
     trace(rp.next());
   }
   else
   {
     trace("no more pages");
   }
}

rs.myMethod(["someParameter",0,50],onrArgs,onfArgs,true); //make a call to get the initial data.
//0 is the offset
//50 is the pagesize
</pre>
<p>In this example, a remoting pager is created in the result callback of the first call. A remoting pager needs at least the first page in order to be created. The RemotingPager takes care of &#8220;pre-fetching&#8221; pages with buffer options. In the above example, where the RemotingPager is created, 50 is the pagesize to grab, 2 is the amount of pages to buffer / pre-fetch. And 1 is the amount of pages that are left in the buffer before triggering another buffer fill / pre-fetch. This is the simplest form of paging, but the RemotingPager has methods for getting certain pages, getting them all, seeking, etc.</p>
<p><strong>UPDATE: I forgot to mention RemotingService.MaxTimeoutsBeforeHault.</strong></p>
<p>With RemotingService.MaxTimeoutsBeforeHault, you can control how many timeouts are allowed from any call, before all remoting calls are stopped. Here&#8217;s a snippet:</p>
<pre>
RemotingService.MaxTimeoutsBeforeHault = 3;
var rs:RemotingService = new RemotingService(rc,"MyService",4000,3,true);
rs.addEventListener(CallEvent.SERVICES_HALTED, onch);
function onch(ce:CallEvent):void{}
rs.myMethod([],onR,onF,true);
</pre>
<p>When you set this property, any call that causes a timeout, is kept track of, and if 3 timeouts happen from any call, no other remoting calls will be made. Each attempt after the services are halted, dispatches the CallEvent.SERVICES_HALTED event.</p>
<p>In conclusion &#8211; SSR gives you logic out of the box that should be available anytime we are using Flash Remoting. And gives you numerous other features. SSR 2 is documented very well in the source files.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2008/01/28/ssr-2-breakdown/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>RubyAMF Generators Project</title>
		<link>http://blog.rubyamf.org/2007/11/12/rubyamf-generators-project/</link>
		<comments>http://blog.rubyamf.org/2007/11/12/rubyamf-generators-project/#comments</comments>
		<pubDate>Tue, 13 Nov 2007 03:46:19 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Generators]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RubyAMF]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=91</guid>
		<description><![CDATA[We&#8217;ve been talking back and forth about some generators for RubyAMF. We all feel they are a good idea, but we didn&#8217;t want to start putting these as part of the RubyAMF core. So, Tony has setup a code-generators for RubyAMF project.  I&#8217;ll voice any new or updated generators here.
]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve been talking back and forth about some generators for RubyAMF. We all feel they are a good idea, but we didn&#8217;t want to start putting these as part of the RubyAMF core. So, Tony has setup a <a href="http://rubyamf-generators.googlecode.com">code-generators for RubyAMF project</a>.  I&#8217;ll voice any new or updated generators here.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2007/11/12/rubyamf-generators-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zlib Byte Array Support</title>
		<link>http://blog.rubyamf.org/2007/11/06/zlib-byte-array-support/</link>
		<comments>http://blog.rubyamf.org/2007/11/06/zlib-byte-array-support/#comments</comments>
		<pubDate>Wed, 07 Nov 2007 05:26:24 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[AMF]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[RubyAMF]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=85</guid>
		<description><![CDATA[We added Zlib compression support for ByteArrays a few days ago. Check out the &#8220;compress&#8221; method on the ByteArray class.
In case any other AMF projects are interested in how we did this &#8211; I&#8217;ve extended the byte array documention here. I also put up a code example.
We&#8217;ve also changed how you receive them in your [...]]]></description>
			<content:encoded><![CDATA[<p>We added Zlib compression support for ByteArrays a few days ago. Check out the <a href="http://livedocs.adobe.com/flex/2/langref/flash/utils/ByteArray.html#compress()">&#8220;compress&#8221;</a> method on the ByteArray class.</p>
<p>In case any other AMF projects are interested in how we did this &#8211; I&#8217;ve extended the byte array documention <a href="http://osflash.org/documentation/amf3">here</a>. I also put up a <a href="http://osflash.org/documentation/amf3/parsing_byte_arrays">code example</a>.</p>
<p>We&#8217;ve also changed how you receive them in your controller action. Previously you&#8217;d get string of bytes. But now we&#8217;re giving you an actual array of bytes. A byte array <img src='http://blog.rubyamf.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>I don&#8217;t have any intention of writing byte array support into the serializer (send byte arrays back to flash from rubyamf). Anyone have any good use for this?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2007/11/06/zlib-byte-array-support/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>RubyAMF &#8211; Skipping 1.3.4 And Writing 1.3.5</title>
		<link>http://blog.rubyamf.org/2007/10/23/rubyamf-skipping-134-and-writing-135/</link>
		<comments>http://blog.rubyamf.org/2007/10/23/rubyamf-skipping-134-and-writing-135/#comments</comments>
		<pubDate>Tue, 23 Oct 2007 07:13:52 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RubyAMF]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=80</guid>
		<description><![CDATA[Surprise! RubyAMF 1.3.5 is under way, and no 1.3.4 will be released.
So here&#8217;s the scoop. Aryk Grosz from MixBook contacted me about using RubyAMF and some experiences he was having. RubyAMF would start to slow down with large complex data structures even slower than WebORB depending on the size, Yikes! Aryk had put time into [...]]]></description>
			<content:encoded><![CDATA[<p>Surprise! RubyAMF 1.3.5 is under way, and no 1.3.4 will be released.</p>
<p>So here&#8217;s the scoop. Aryk Grosz from MixBook contacted me about using RubyAMF and some experiences he was having. RubyAMF would start to slow down with large complex data structures even slower than WebORB depending on the size, Yikes! Aryk had put time into optimizing RubyAMF and you would not believe the results we&#8217;re getting.</p>
<p>I went down to <a href="http://www.mixbook.com">Mixbook</a> in San Jose on Sunday and spent a little time with Aryk ripping apart RubyAMF. So we&#8217;ve pretty much re-written RubyAMF, here&#8217;s a brief rundown of what&#8217;s going on.</p>
<p>First let&#8217;s talk restructure. We ripped out 60% of the code base which was legacy from RAMFL. I won&#8217;t go into the gory details but we&#8217;ve re-arranged a lot, changed a lot of names. For example ValueObjects are now ClassMappings. Which is more appropriate because RAMF has full class mapping support. We&#8217;ve also put an init.rb file in the plugin so all the requires get done on application startup.</p>
<p>There are a couple other features we&#8217;ve added to class mapping definitions, such as the :associations, :attributes, and :ignore_fields properties. The :ignore_fields is just like it sounds, for a specific class mapping you can ignore specific properties on it. You can also define a global ignore fields like so: ClassMappings.ignore_fields.</p>
<p>The :associations and :attributes are for performance reasons. You aren&#8217;t required to use them, but if you do it speeds up the serializer even more. We&#8217;ve also change the names of :incoming / :map_to / <img src='http://blog.rubyamf.org/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> utgoing to :actionscript / :ruby.</p>
<p>Performance! This thing is about 5x faster. As an example, a data structure of about 1500 objects that&#8217;s used in Mixbook takes around 35 seconds with WebORB. RAMF averages 2.4 seconds. Sweet! You can even see the speed increase on one object. It&#8217;s that much faster.</p>
<p>We also decreased the size of the data transfer. As an example, let&#8217;s say an AMF message was 250K, it would now be about 100K. That&#8217;s a huge difference.</p>
<p>That&#8217;s just a small preview of what&#8217;s going on. Sorry for the inconvenience of not getting 1.3.4 done last week, but as soon as we started these changes and optimizations &#8211; 1.3.4 was obsolete.</p>
<p>So hats off to Aryk for the help, he did a most of the speed optimizations and has been refactoring and writing a ton for RubyAMF. Thanks for the help!</p>
<p>And to top it all off, RubyAMF will have it&#8217;s first &#8220;in production&#8221; customer over at MixBook. They&#8217;re working on re-factoring their rails app to use RubyAMF. Awesome!</p>
<p>-Aaron</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2007/10/23/rubyamf-skipping-134-and-writing-135/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>RubyAMF 1.3.4 Preview</title>
		<link>http://blog.rubyamf.org/2007/10/16/rubyamf-134-preview/</link>
		<comments>http://blog.rubyamf.org/2007/10/16/rubyamf-134-preview/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 07:14:40 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RubyAMF]]></category>
		<category><![CDATA[Team]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=77</guid>
		<description><![CDATA[Just in case you&#8217;re not on the mailing list. I sent out a 1.3.4 Preview release announcement. Read it here.
]]></description>
			<content:encoded><![CDATA[<p>Just in case you&#8217;re not on the mailing list. I sent out a 1.3.4 Preview release announcement. <a href="http://groups.google.com/group/adobe-rubyonrails-ria-sdk/browse_thread/thread/38ed9be3b76cf6ba">Read it here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2007/10/16/rubyamf-134-preview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Remoting Parameter Mapping Feature</title>
		<link>http://blog.rubyamf.org/2007/10/13/new-remoting-parameter-mapping-feature/</link>
		<comments>http://blog.rubyamf.org/2007/10/13/new-remoting-parameter-mapping-feature/#comments</comments>
		<pubDate>Sat, 13 Oct 2007 08:14:55 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[RubyAMF]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=75</guid>
		<description><![CDATA[To whet your RubyAMF appetite a little more. We&#8217;ve added in a new feature that will be in 1.3.4. This new feature allows you to map incoming remoting parameters to to params[:] hash how ever you like.
As a quick example, let&#8217;s say you wanted to map the &#8220;id&#8221; property of a &#8220;User&#8221; object to the [...]]]></description>
			<content:encoded><![CDATA[<p>To whet your RubyAMF appetite a little more. We&#8217;ve added in a new feature that will be in 1.3.4. This new feature allows you to map incoming remoting parameters to to params[:] hash how ever you like.</p>
<p>As a quick example, let&#8217;s say you wanted to map the &#8220;id&#8221; property of a &#8220;User&#8221; object to the params[:id] key. Here&#8217;s how you&#8217;d do it.</p>
<p>Here&#8217;s an example actionscript remoting call:</p>
<pre>
 service = new RemotingService("...","UserController",3);
 service.destroy([myUser],result,fault);
</pre>
<p>And the supporting RubyAMF configuration to accomplish this mapping:</p>
<pre>
Parameter::Map.register({
 :controller => :UserController,
 :action => :destroy,
 :params => { :id => "{0}.id" }
})
</pre>
<p>This is a big improvement over the old way, which would only map the first parameter into the params[:] hash, you can decide what gets put where.</p>
<p>As another example. If you wanted to map the 3rd arguments &#8220;firstname&#8221; property to &#8220;params[:firstname]&#8220;. You&#8217;d do this:</p>
<p>AS:</p>
<pre>
 service.myaction([...,...,thirdObject],result,fault);
</pre>
<p>Config:</p>
<pre>
Parameter::Map.register({
 :controller => :UserController,
 :action => :myaction,
 :params => { :firstname => "{2}.firstname" }
})
</pre>
<p>As mentioned, this will hit in 1.3.4. Hope it&#8217;s useful <img src='http://blog.rubyamf.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  -A</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2007/10/13/new-remoting-parameter-mapping-feature/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RubyAMF Updates</title>
		<link>http://blog.rubyamf.org/2007/10/07/rubyamf-updates/</link>
		<comments>http://blog.rubyamf.org/2007/10/07/rubyamf-updates/#comments</comments>
		<pubDate>Sun, 07 Oct 2007 18:54:25 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Remoting]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RubyAMF]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=68</guid>
		<description><![CDATA[Now that I&#8217;m officially back from vaca &#8211; here&#8217;s a quick update on what&#8217;s up with RubyAMF.
First I&#8217;d like to officially welcome Seth Tenenbaum to RubyAMF. He started helping quite a bit and his efforts are so much appreciated.
Next is some project maintenance and installing some software to work better for future developers and community. [...]]]></description>
			<content:encoded><![CDATA[<p>Now that I&#8217;m officially back from vaca &#8211; here&#8217;s a quick update on what&#8217;s up with RubyAMF.</p>
<p>First I&#8217;d like to officially welcome Seth Tenenbaum to RubyAMF. He started helping quite a bit and his efforts are so much appreciated.</p>
<p>Next is some project maintenance and installing some software to work better for future developers and community. I&#8217;ll be moving SVN over to my dedicated server. The SVN move is for a new Trac install.</p>
<p>I changed the forum install to phpBB. And of course the wiki is being neglected for work on RubyAMF. You can still access the old wiki <a href="http://rubyamf.org:2500/">here.</a></p>
<p>And I&#8217;m sure some are wondering about the next release. We&#8217;ve got a pretty short bug list, but the bugs are critical. Once those are all fixed 1.3.4 will be released. Seth, Tony, and myself are working on bug fixes and feature additions.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2007/10/07/rubyamf-updates/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Development Efforts</title>
		<link>http://blog.rubyamf.org/2007/10/01/development-efforts/</link>
		<comments>http://blog.rubyamf.org/2007/10/01/development-efforts/#comments</comments>
		<pubDate>Tue, 02 Oct 2007 03:09:06 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RubyAMF]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=67</guid>
		<description><![CDATA[As you&#8217;ve probably seen I&#8217;m working on finding some people for support development on RubyAMF. Quite a few people are interested with RubyAMF, and Rails 2 support and feature additions need to be done as soon as rails 2 is ready. So I&#8217;m gearing up for that hopefully with some help. There should be plenty [...]]]></description>
			<content:encoded><![CDATA[<p>As you&#8217;ve probably seen I&#8217;m working on finding some people for support development on RubyAMF. Quite a few people are interested with RubyAMF, and Rails 2 support and feature additions need to be done as soon as rails 2 is ready. So I&#8217;m gearing up for that hopefully with some help. There should be plenty of time for dev as Rails 2 is only in a preview release state.</p>
<p>Hang in everyone! I&#8217;ll officially be back from vacation on the 8th to release 1.3.4 and gear up for the next dev tasks. Additionally I don&#8217;t see any major conflicts with RubyAMF and Rails 2, as there is only one entry point into Rails (aside from the rubyamf controller).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2007/10/01/development-efforts/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>RubyAMF too Dark?</title>
		<link>http://blog.rubyamf.org/2007/09/20/rubyamf-too-dark/</link>
		<comments>http://blog.rubyamf.org/2007/09/20/rubyamf-too-dark/#comments</comments>
		<pubDate>Thu, 20 Sep 2007 18:02:36 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RubyAMF]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=53</guid>
		<description><![CDATA[So maybe this isn&#8217;t a question you were expecting. But does anyone else have any problems with the colors / brightness on RubyAMF? This post didn&#8217;t include RubyAMF. Apparently because it&#8217;s too dark to read. Which is alright. But it makes me want to hear from more people. Should I re-skin the site to be [...]]]></description>
			<content:encoded><![CDATA[<p>So maybe this isn&#8217;t a question you were expecting. But does anyone else have any problems with the colors / brightness on RubyAMF? <a href="http://www.flex888.com/2007/09/20/10-flex-and-ruby-on-rails-integration-examples.html">This post</a> didn&#8217;t include RubyAMF. Apparently because it&#8217;s too dark to read. Which is alright. But it makes me want to hear from more people. Should I re-skin the site to be mostly white with some red? I&#8217;m on a mac so the brightness / gamma is different and it shines for me <img src='http://blog.rubyamf.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>RubyAMF is getting to the point where it&#8217;s a great experience tying it in with Rails (and of course with Lite) &#8211; the fact that it works with scaffolding and in your controller with render :amf makes it a winner for me. But if people don&#8217;t use it because they can&#8217;t read the site then it&#8217;s time for an update. I love working on RubyAMF so I want everyone to have a great experience with it. Maybe this sounds weird &#8211; but I LOVE remoting. The first project I did with remoting was with <a href="http://www.mercurycloud.com">MercuryCloud</a> and <a href="www.5etdemi.com/blog">Patrick Mineault</a>.  Ever since then it&#8217;s been a key part of almost every project I build. So I&#8217;m not trying to be pushy about RubyAMF at all, just know that everything I put into RubyAMF is pretty carefully thought out for performance factor and ease of use.</p>
<p>What do you think, time for a re-skin or color update?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2007/09/20/rubyamf-too-dark/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>RubyAMF. Flash. And Rails&#8217; Params</title>
		<link>http://blog.rubyamf.org/2007/09/18/rubyamf-flash-and-rails-params/</link>
		<comments>http://blog.rubyamf.org/2007/09/18/rubyamf-flash-and-rails-params/#comments</comments>
		<pubDate>Tue, 18 Sep 2007 07:22:23 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RubyAMF]]></category>

		<guid isPermaLink="false">http://blog.rubyamf.org/?p=50</guid>
		<description><![CDATA[I&#8217;d like to shed a little more light on the best ways to send parameters to RubyAMF Rails, so that you can use params[:]. Specifically using Flash 9, NOT Flex. The most important two things to note are these:

Any objects properties whether it be a basic object, or value object get merged into the params [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to shed a little more light on the best ways to send parameters to RubyAMF Rails, so that you can use params[:]. Specifically using Flash 9, NOT Flex. The most important two things to note are these:</p>
<ul>
<li>Any objects properties whether it be a basic object, or value object get merged into the params hash. ONLY the first parameter gets merged though.</li>
<li>Any incoming value object also gets put into params[:classtype]. So if an incoming VO is of the type &#8220;vo.Event&#8221;, it will be put in params[:event]. This will enable you to fully use scaffolding without adding is_amf conditionals.</li>
</ul>
<p>So what does this mean? If you send parameters correctly from Flash, there are only a few updates to get everything working correctly on the rails side. Here&#8217;s a generic example that should translate to a real working example.</p>
<p>RAILS:</p>
<pre>
class MyService < ActionController
  def update
    user = User.find(params[:id])
    if is_amf
      u = user.update_attributes(:name => params[:name], :email => params[:email])
    else
      user = User.find(:id)
    end
    if u
      render :amf => true
    end
  end

  def create
   if is_amf
     user = User.new({:name => params[:name], :email => params[:email]})
   else
     user = User.new(params[:user])
   end
   if user.save
     render :amf => true
   end
  end

  def destroy
   user = User.find(params[:id])
   user.destroy
   render :amf => true
  end
end
</pre>
<p>So in this example the destroy method works without having to mix in the is_amf variable. The create and update method has to mix in the is_amf variable because we&#8217;re not passing value objects back and forth.</p>
<p>Here is the corresponding AS3 to call these methods correctly.</p>
<p>AS3</p>
<pre>
function createUser():void
{
  myservice.create([{name:'asdfasdf',email:'aaron'}], onResult,onFault);
}

function updateUser(user:Object):void
{
   //user should be  => {id:1, name:'Aaron', email:'aaron@something.com'}
   myservice.update([user],onResult,onFault);
}

function destroyUser(id:Number):void
{
  myservice.destroy([{id:id}],onResult,onFault);
}
</pre>
<p>So what do we do to update the create and update methods so they don&#8217;t have to use is_amf? Value objects or _explicitType. These are two options to help you map everything the way you want. Here&#8217;s how they both work.</p>
<p>Value objects are simple. They boil down to a generic object with one extra piece of information &#8211; the class type. In our case. A &#8216;User&#8217; class. So when you instantiate a value object, and send it over to RubyAMF, all your properties come over in a generic object, but it also sends the class type. Pretty simple. On the RubyAMF side your class type is caught and a Value Object of the same type is instantiated in Ruby / Rails. So if your value object is a User class, it is in turned mapped to params[:user].</p>
<p>So do we absolutely need value objects to get the params[:user] hash to be the correct object? No. RubyAMF uses a special property to handle value objects on the server side. _explicitType. If you send a generic object with the _explicitType property, it will be turned into a corresponding value object for you. It just so happens that the _explicitType is used to map a value object class to params[:classtype]. So we can use this to map our generic object to the params[:user].</p>
<p>Let&#8217;s look at how we can update methods so we don&#8217;t need to use is_amf.</p>
<p>Rails:</p>
<pre>
def create
  user = User.new(params[:user])
  if user.save
    render :amf => user.as_single!
  end
end

def update
  user = User.find(params[:id])
  if user.update_attributes(params[:user])
    render :amf => true
  end
end
</pre>
<p>AS3</p>
<pre>
function createUser():void
{
  myservice.create([{_explicitType:'user', name:'Aaron', email:'aaron@something.com'}],onResult,onFault);
}
function updateUser(user):void
{
  //uyser should be => {id:1, _explicitType:'user', name:"Aaron", email:"myemail"}
  myservice.update([user],onResult,onFault)
}
</pre>
<p>So by specifying the _explicitType property, it&#8217;s going to put an active record update_hash in params[:user]. Pretty cool. Now I&#8217;m not suggesting you use _explicitType at all times as it&#8217;s kind of a hack. You should use value objects instead. But hey, you&#8217;ll probably benefit from knowing more about RubyAMF.</p>
<p>Please let me know if there are any questions or suggestions for making it better.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rubyamf.org/2007/09/18/rubyamf-flash-and-rails-params/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
