tag:blogger.com,1999:blog-61773377922400279052024-02-08T09:48:45.634-08:00Flex On RailsDaniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-6177337792240027905.post-55390820078054383902009-05-03T14:38:00.001-07:002009-05-03T14:40:20.309-07:00Flex on Rails book source code updated for Rails 2.3.2Rails 2.3.2 introduces some changes that required that we adapted the code from our book. I just reviewed and update the code for chapter 2,3,4,7,18,20 and 22 to run with Rails 2.3.2 and Flex SDK 3.3. Tony will do some more work on checking RubyAMF and the chapters he wrote code for. So here is quick look at the changes: <br /><br />- In Rails 2.3.2 the file containing the application controller class must be renamed from application.rb to application_controller.rb. <br /><br />- Another change introduce since the new rack middleware stack is that adding _method=put to the url isn't recognized by rails in the case of a post. However it's still recognized for the delete, so I am not sure what's going on and if the Rails guys will reinstate the _method= in the near future. Fortunately Rails recognizes the X_HTTP_METHOD_OVERRIDE request header. So for updates we set this header in Flex. Now Flex doesn't set the headers if the body of the message is empty like for delete, so we still use the _method=delete for deletes. It would be nice to be able to set this in a consistent manner for both deletes and updates. <br /><br />- On chapter 04 on testing with <a href="http://code.google.com/p/fluint/">Fluint</a> we moved to using fluint 1.1.1, and no changes was require for this. <br /><br />- On chapter 20 Server Push with Juggernaut I updated using the latest plugin downloaded from github and no more the code from rubyforge and updated gem version for eventmachine to 0.12.6 and the json gem to 1.1.4. So installing the plugin is now done with the following command:<br /><br /><pre><br />./script/plugin install git://github.com/maccman/juggernaut_plugin.git<br /></pre><br /><br />If you find any other issues with Rails 2.3.2. send me an email or leave a comment on this blog post. Thanks to all the readers that submitted comments so far.<br /><br />Enjoy!<br />Daniel<br />Daniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.com3tag:blogger.com,1999:blog-6177337792240027905.post-87999268727831862942009-03-15T17:58:00.001-07:002009-03-15T17:58:26.541-07:00Flex on Rails presentation at RMAUG on March 10thThis is the edited version of the talk Tony Hillerson and Daniel Wanja gave at the Rocky Mountain Adobe User Group on March 10th. There is an echo the first two minutes, then the sounds stabilize. We also had a software issue on Tony's notebook and display port issue on Daniel's, parts which I edited out. The demo gods where not with us that night :-), but we had fun and I hope we answered many of the questions the attendance had. Also we wanted to tailor the talk on Ruby on Rails rather than on Flex and be an open format, but we had more questions than anticipated and presented only 10% of the material we had. <br /><br /><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3671443&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3671443&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object><br /><a href="http://vimeo.com/3671443">Flex on Rails presentation at RMAUG on March 10th</a> from <a href="http://vimeo.com/user507500">daniel wanja</a> on <a href="http://vimeo.com">Vimeo</a>.<br />Note: during the first 2 minutes there is an echo. Sound skips from time to time throughout the video.<br /><br />The talk was recorded by RMAUG and posted on <a href="http://www.rmaug.com/community/forum/messageview.cfm?catid=5&threadid=124&messid=192">their blog</a>, and can be viewed using Connect <a href="http://realeyes.acrobat.com/p49039280/">here</a>. <br /><br />Thanks again to everyone who attended!<br /><br />Daniel.Daniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.com0tag:blogger.com,1999:blog-6177337792240027905.post-49103875832355903322009-03-09T12:33:00.000-07:002009-03-11T12:10:56.940-07:00File Upload with Multipart Request - revisitedIn the file upload chapter of the book I show how to create a multipart request to upload an image to a Rails server. On a client project I needed to send some XML and two images in one post to a Rails application. Mike, over at <a href="http://www.mikestead.co.uk">http://www.mikestead.co.uk</a>, wrote a nice framework to create multipart requests in an ActionScript like fashion which would make this easier. You can read the whole article over at http://www.mikestead.co.uk/2009/01/04/upload-multiple-files-with-a-single-request-in-flash/. However, I tried his out and it didn't work with Rails. After some debugging and a little tweaking I made it work, you will find the fix at the end of this article. So let's look at an example (from my client project, used without authorization ;-):<br/><br /><pre class="textmate-source all_hallow_s_eve"><span class="text text_xml text_xml_mxml"><span class="source source_actionscript source_actionscript_3 source_actionscript_3_embedded source_actionscript_3_embedded_mxml"><span class="storage storage_modifier storage_modifier_actionscript storage_modifier_actionscript_3">private</span> <span class="storage storage_type storage_type_actionscript storage_type_actionscript_3">function</span> sendToServer(planId<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">:</span><span class="support support_type support_type_function support_type_function_global support_type_function_global_actionscript support_type_function_global_actionscript_3">String</span>, plan<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">:</span><span class="support support_type support_type_function support_type_function_global support_type_function_global_actionscript support_type_function_global_actionscript_3">XML</span>, patternBitmap<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">:</span><span class="support support_class support_class_flash support_class_flash_actionscript support_class_flash_actionscript_3">Bitmap</span>, layoutBitmap<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">:</span><span class="support support_class support_class_flash support_class_flash_actionscript support_class_flash_actionscript_3">Bitmap</span>)<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">:</span><span class="keyword keyword_special-type keyword_special-type_actionscript keyword_special-type_actionscript_3">void</span> <span class="meta meta_function meta_function_actionscript meta_function_actionscript_3">{<br /> <span class="storage storage_type storage_type_actionscript storage_type_actionscript_3">var</span> variables<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">:</span><span class="support support_class support_class_flash support_class_flash_actionscript support_class_flash_actionscript_3">URLVariables</span> <span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">=</span> <span class="keyword keyword_operator keyword_operator_actionscript keyword_operator_actionscript_3">new</span> <span class="support support_class support_class_flash support_class_flash_actionscript support_class_flash_actionscript_3">URLVariables</span>()<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">;</span> <br /> variables<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span>quilt_plan <span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">=</span> plan<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span><span class="support support_function support_function_top-level support_function_top-level_actionscript support_function_top-level_actionscript_3">toXMLString</span>()<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">;</span><br /> variables<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span>pattern_image <span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">=</span> <span class="keyword keyword_operator keyword_operator_actionscript keyword_operator_actionscript_3">new</span> URLFileVariable(<span class="keyword keyword_operator keyword_operator_actionscript keyword_operator_actionscript_3">new</span> <span class="support support_class support_class_mx support_class_mx_actionscript support_class_mx_actionscript_3">PNGEncoder</span>()<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span><span class="support support_function support_function_mx support_function_mx_actionscript support_function_mx_actionscript_3">encode</span>(patternBitmap<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span><span class="support support_property support_property_mx support_property_mx_actionscript support_property_mx_actionscript_3">bitmapData</span>), <span class="string string_quoted string_quoted_double string_quoted_double_actionscript string_quoted_double_actionscript_3">"pattern_image.png"</span>)<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">;</span><br /> variables<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span>layout_image <span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">=</span> <span class="keyword keyword_operator keyword_operator_actionscript keyword_operator_actionscript_3">new</span> URLFileVariable(<span class="keyword keyword_operator keyword_operator_actionscript keyword_operator_actionscript_3">new</span> <span class="support support_class support_class_mx support_class_mx_actionscript support_class_mx_actionscript_3">PNGEncoder</span>()<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span><span class="support support_function support_function_mx support_function_mx_actionscript support_function_mx_actionscript_3">encode</span>(layoutBitmap<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span><span class="support support_property support_property_mx support_property_mx_actionscript support_property_mx_actionscript_3">bitmapData</span>), <span class="string string_quoted string_quoted_double string_quoted_double_actionscript string_quoted_double_actionscript_3">"layout_image.png"</span>)<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">;</span><br /> <span class="storage storage_type storage_type_actionscript storage_type_actionscript_3">var</span> <span class="support support_property support_property_mx support_property_mx_actionscript support_property_mx_actionscript_3">request</span><span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">:</span><span class="support support_class support_class_flash support_class_flash_actionscript support_class_flash_actionscript_3">URLRequest</span> <span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">=</span> <span class="keyword keyword_operator keyword_operator_actionscript keyword_operator_actionscript_3">new</span> URLRequestBuilder(variables)<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span>build()<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">;</span><br /> <span class="support support_property support_property_mx support_property_mx_actionscript support_property_mx_actionscript_3">request</span><span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span><span class="support support_property support_property_mx support_property_mx_actionscript support_property_mx_actionscript_3">url</span> <span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">=</span> <span class="string string_quoted string_quoted_double string_quoted_double_actionscript string_quoted_double_actionscript_3">"/quilt_plans/"</span><span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">;</span><br /> <span class="support support_property support_property_mx support_property_mx_actionscript support_property_mx_actionscript_3">request</span><span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span><span class="support support_property support_property_mx support_property_mx_actionscript support_property_mx_actionscript_3">method</span> <span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">=</span> <span class="support support_class support_class_flash support_class_flash_actionscript support_class_flash_actionscript_3">URLRequestMethod</span><span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span><span class="constant constant_language constant_language_conventional constant_language_conventional_actionscript constant_language_conventional_actionscript_3">POST</span><span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">;</span><br /><br /> <span class="support support_property support_property_flash support_property_flash_actionscript support_property_flash_actionscript_3">loader</span> <span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">=</span> <span class="keyword keyword_operator keyword_operator_actionscript keyword_operator_actionscript_3">new</span> <span class="support support_class support_class_flash support_class_flash_actionscript support_class_flash_actionscript_3">URLLoader</span>(<span class="support support_property support_property_mx support_property_mx_actionscript support_property_mx_actionscript_3">request</span>)<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">;</span><br /> <span class="support support_property support_property_flash support_property_flash_actionscript support_property_flash_actionscript_3">loader</span><span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span><span class="support support_function support_function_mx support_function_mx_actionscript support_function_mx_actionscript_3">addEventListener</span>(<span class="support support_class support_class_flash support_class_flash_actionscript support_class_flash_actionscript_3">Event</span><span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span><span class="constant constant_language constant_language_conventional constant_language_conventional_actionscript constant_language_conventional_actionscript_3">COMPLETE</span>, completeHandler)<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">;</span> <br /> <span class="support support_property support_property_flash support_property_flash_actionscript support_property_flash_actionscript_3">loader</span><span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_dot keyword_operator_symbolic_dot_actionscript keyword_operator_symbolic_dot_actionscript_3">.</span><span class="support support_function support_function_mx support_function_mx_actionscript support_function_mx_actionscript_3">load</span>(<span class="support support_property support_property_mx support_property_mx_actionscript support_property_mx_actionscript_3">request</span>)<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">;</span> <br /> }</span><br /> </span></span></pre><br /><br />As you see using the URLFileVariable and URLRequestBuilder is pretty straight forward. In the above example we first add some XML to the URLVariable:<br /><pre><br /> variables.quilt_plan = plan.toXMLString();<br /></pre><br /><br />Then we add the bitmap data of an image:<br /><pre><br /> variables.pattern_image = new URLFileVariable(new PNGEncoder().encode(patternBitmap.bitmapData), "pattern_image.png");<br /></pre><br /><br />We add a second image named layout_image in the similar manner. Finally we use the build method of the URLRequestBuilder to create a multipart request.<br /><pre><br /> var request:URLRequest = new URLRequestBuilder(variables).build();<br /></pre><br /><br />This request can then be passed to the load method of a standard URLLoader to send two images and an XML document in one swoop.<br /><br />On the Rails side in our controller <br /><br /><pre class="textmate-source all_hallow_s_eve"><span class="source source_ruby source_ruby_rails"><span class="meta meta_rails meta_rails_controller"> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>quilt_plan</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="support support_class support_class_ruby">QuiltPlan</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span><span class="keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby">new</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>quilt_plan_calculations</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=></span> params<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>quilt_plan</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span><br /> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>quilt_plan</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>build_layout_image<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>uploaded_data</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=></span> params<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>layout_image</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <br /> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>quilt_plan</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>build_pattern_image<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>uploaded_data</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=></span> params<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">[</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>pattern_image</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span></span></span><br /></pre><br /> <br />Now the params argument passed to your Rails action method contains the XML in the params[:quilt_plan] variable, and the two images ready for upload in params[:layout_image] and params[:pattern_image]. You could do params[:layout_image].read to get the image, or as with our example the attachment_fu plugin does it for us.<br /><br />Et voila...happy multipart requesting!<br /><br /><p/>Rails did have issues with the way the request was created and I applied the following changes which mainly just changes the Line Feed send in the requests in URLRequestBuilder.as:<br /><br /> <pre><br /> < private static const LF:String = "\r\n";<br /> ---<br /> > private static const LF:String = "\n";<br /> 187,188c185<br /> < field.writeUTFBytes(MULTIPART_MARK + MULTIPART_BOUNDARY + LF +<br /> ---<br /> > field.writeUTFBytes(LF + MULTIPART_MARK + MULTIPART_BOUNDARY + LF +<br /> 191a189<br /> > <br /> 208,209c206<br /> < field.writeUTFBytes(MULTIPART_MARK + MULTIPART_BOUNDARY + LF +<br /> ---<br /> > field.writeUTFBytes(LF + MULTIPART_MARK + MULTIPART_BOUNDARY + LF +<br /> </pre><br /><br />Enjoy!<br />DanielDaniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.com6tag:blogger.com,1999:blog-6177337792240027905.post-87458686882400303712009-01-29T18:37:00.001-08:002009-01-29T18:37:40.517-08:00Upside down chapters?<p style="clear: both">The other day while giving away seven books at the Derailed (Denver Ruby on Rails User Group) one attendee noticed that one the books had some chapters that where upside down (around page 166). I didn't think much of it, but today a coworker from Tony who bought the book noticed the same thing. All the pages are there but for some of the chapters you will need to turn the book upside down. Please drop us a line (d[at]n-so.com) if you experience the same. I am not sure how broad the issue is and in fact it's out of my hands, but we would like to keep the publisher informed of this. I am not sure how they deal with a situation like that, but let's find out.<br /><br /></p><br class='final-break' style='clear: both' />Daniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.com1tag:blogger.com,1999:blog-6177337792240027905.post-22321160073915703722009-01-26T20:38:00.000-08:002009-01-26T20:50:49.897-08:00Moving RailsConf apps to herokugarden.com<a href="http://www.flexonrails.com/air_apps.html">Three applications</a> from our RailsConf talk where deployed using heroku.com. I just realized last week that they moved the apps that where deployed on their closed beta environment to their new free offering <a href="herokugarden.com">herokugarden.com</a> environment. <a href="heroku.com">heroku.com</a> will be the place for their commercial Rails hosting offering. No need to say that I am waiting eagerly to try it out. The impact was that the application they moved to herokugarden required a migration to be run. But besides that the move was straight forward. A couple of things to know which are described more in details on <a href="http://herokugarden.com/transition">their transition page</a> but to migrate an existing app to the garden if followed these three steps:<br /><br />1. 'sudo gem install herokugarden'<br />2. From your application folder 'herokugarden git:transition'<br />3. If you encounter an Application Failure doing a 'git push', you need to fix your .git/config file as follows:<br /><pre><br />[remote "heroku"]<br /> url = git@heroku.com:rc-10-twitterfriends.git<br /> fetch = +refs/heads/*:refs/remotes/heroku/*<br /></pre><br />to <br /><pre><br />[remote "origin"]<br /> url = git@herokugarden.com:rc-10-twitterfriends.git<br /> fetch = +refs/heads/*:refs/remotes/origin/*<br /></pre><br /><br />You can download the new apps here:<br /><br /><a href="http://www.flexonrails.com/air_apps/apps/S3Browser.air">http://www.flexonrails.com/air_apps/apps/S3Browser.air</a><br /><a href="http://www.flexonrails.com/air_apps/apps/PhotoBooth.air">http://www.flexonrails.com/air_apps/apps/PhotoBooth.air</a><br /><a href="http://www.flexonrails.com/air_apps/apps/TwitterFriends.air">http://www.flexonrails.com/air_apps/apps/TwitterFriends.air</a>Daniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.com0tag:blogger.com,1999:blog-6177337792240027905.post-84449186640433236342009-01-23T19:48:00.000-08:002009-01-23T19:51:48.651-08:00Flex on Rails Talk in Denver: Thank you!Thanks to everyone that attended, it was a fun meet. <br />You can fine the slides here after and the link to the source on http://www.flexonrails.com/flex_apps.html.<br /><br /><div style="width:425px;text-align:left" id="__ss_948367"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/danielwanja/flexonrails-derailed-talk-presentation?type=powerpoint" title="Flexonrails Derailed Talk">Flexonrails Derailed Talk</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=flexonrailsderailedtalk-1232768578449618-3&stripped_title=flexonrails-derailed-talk-presentation" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=flexonrailsderailedtalk-1232768578449618-3&stripped_title=flexonrails-derailed-talk-presentation" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object><div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> or <a style="text-decoration:underline;" href="http://www.slideshare.net/upload?type=powerpoint">upload</a> your own. (tags: <a style="text-decoration:underline;" href="http://slideshare.net/tag/flex">flex</a> <a style="text-decoration:underline;" href="http://slideshare.net/tag/rails">rails</a>)</div></div>Daniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.com0tag:blogger.com,1999:blog-6177337792240027905.post-55145601441366564782009-01-19T15:42:00.000-08:002009-01-19T15:45:31.702-08:00Flex On Rails talk in Denver - Thursday 22ndTony and I will be giving a talk on Flex on Rails at Derailed, the Denver Rails User Group. This will take place at <a href="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=forest+room+denver&sll=37.0625,-95.677068&sspn=37.410045,79.365234&ie=UTF8&ll=39.759991,-105.011272&spn=0.035498,0.077505&t=h&z=14&iwloc=A">Forest Room 5</a> in <span class="caps">LODO</span> at 6:30pm, this coming Thursday 22nd.<br /></br>On the agenda.<br /> <ul><br /> <li>6:30 – 7:00: Meet and mingle</li><br /> <li>7:00 – 8:30: Flex on Rails – From the authors Daniel Wanja and Tony Hillerson</li><br /> <li>8:30 – ... : Book raffle and spirits.</li><br /> </ul><br />We will show highlights of each of the chapters and samples from the book.</br><br />I hope to see you there!<br />DanielDaniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.com0tag:blogger.com,1999:blog-6177337792240027905.post-10619127196916732712009-01-02T20:16:00.000-08:002009-01-02T20:17:44.113-08:00New Book: "Flex on Rails: Building Rich Internet Applications with Adobe Flex 3 and Rails 2"<div style="text-align:center;"><img src="http://onrails.org/files/2009.01.02_CoverSmall.jpg" alt="2009.01.02 CoverSmall.jpg" border="0" width="500" height="333" /></div><br /><br />Finally our book on using Flex with Rails is released and will appear over the next few days in stores around the US and is available on <a href="http://www.amazon.com/gp/product/0321543378?ie=UTF8&tag=flexonrails-20&linkCode=as2&camp=1789&creative=9325&creativeASIN=0321543378">Amazon</a>. I received a couple of copies from the publisher and it felt like an accomplishment to hold a physical version in my hands. I am sure my co-author, <a href="http://thillerson.blogspot.com/">Tony</a>, felt the same. Good job man! With this release we are also launching <a href="http://flexonrails.com">http://flexonrails.com</a> where you can find all the source code of the book as well as other resources related to Flex and Rails, and our blog <a href="http://blog.flexonrails.com">http://blog.flexonrails.com</a> the blog for everything on Flex with Ruby On Rails...<br /><br />So here are the top 10 reasons why should you absolutely buy this book even if you are not a programmer....1) Your vision will improve 2) You'll run faster 3) Aging gets reverted 4)... Just kidding, the main reasons for us to write this book was that we really wanted to share many of the experiences and findings we had on using Flex and Rails on many projects, and we are proud of the outcome. It's a book by developers for developers. I'll be blogging in a next entry about the process of writing this book, and will create a screencast presenting the different applications we are creating in the book, so stay tuned. When writing the book we assumed that you where a developer, either a Flex developer or a Rails developer that needed to interact with the other side and wanted to add Rails or Flex to it's battery of languages. You will certainly find your way around even if you don't know Flex or Rails. In either case we didn't create a reference book so you won't find all the answers about each api that is available in both frameworks, but you will find everything you need to get started integrating Flex with Rails, and delve into wonderful world of Flex on Rails applications. For the example code we didn't want to build a large application and refine it over time through the chapters, so most chapter contain one or several working applications used to highlight the major integration aspects explained in that chapter. And Rails is just fantastic to create small applications on the fly, and Flex and Actionscript is pretty good for that too. So to give you a better overview of the content of this book I have attached the official description and the table of content. For more info come back to <a href="http://blog.flexonrails.com">http://blog.flexonrails.com</a> and <a href="http://flexonrails.com">http://flexonrails.com</a>. I hope you enjoy the book and the sample applications. So go check it out and let us know what you think.<br /><br />Daniel.<br /><br /><br /><br /><h2>Description</h2><br /><br />“There’s no question you’re going to be a better Flex and Rails developer when you’re done reading this book.”<br />–From the Foreword by Matt Chotin, Senior Product Manager, Adobe Systems, Inc.<br /><br /> <br />Adobe Flex enables the rapid development of rich and engaging user experiences. Ruby on Rails dramatically simplifies the development of database-driven web applications. Now there’s a book that shows how to use the newest versions of both frameworks together to create state-of-the-art Rich Internet Applications (RIAs).<br /><br /> <br />Flex on Rails begins with the absolute essentials: setting up your environment for Flex and Rails, passing data with XML, and integrating Flex front-ends with Rails back-ends. Then, using practical, easy-to-understand code examples, the authors take you from the basics to advanced topics only discussed in this book. Techniques covered here include <br /><br />* Constructing sophisticated interfaces that can’t be created with AJAX alone<br /><br />* Using RESTful services to expose applications for access via APIs<br /><br />* Testing Flex and Rails together<br /><br />* Using Flex Frameworks<br /><br />* Getting Flex into your build/deploy process<br /><br />* And more… <br /><br />The authors also offer practical introductions to powerful complementary technologies, such as RubyAMF and Juggernaut.<br /> <br /><br />Written by developers with extensive experience using both frameworks, this book covers the new Adobe Flex 3 and Ruby on Rails 2 from the ground up. Even if you have minimal experience with Flex or Rails, you’ll learn all you need to know to use them to build exceptional production applications.<br /><br /><br /><h2>Table of Contents</h2><br /><pre><br />Foreword xv<br />Preface xvii<br />Acknowledgments from Tony Hillerson xxi<br />Acknowledgments from Daniel Wanja xxii<br />About the Authors xxiv<br /> <br /><strong>PART I: Flex and Rails Essentials</strong><br /> <br />Chapter 1: Developing with Flex and Rails 3<br />Installation: What You Need to Get Running 3<br />The Structure of a Flex and Rails Application 6<br />The Example Code 9<br />Compiling MXML 9<br />Running the Rails Server 9<br />Summary 9<br /> <br />Chapter 2: Passing Data with XML 11<br />XML in Rails 11<br />XML in Flex 14<br />Getting XML to Flex 17<br />Sending XML to Rails 19<br />Mapping Data Types 21<br />Error Handling 25<br />Summary 28<br /> <br />Chapter 3: Flex with RESTful Services 29<br />Creating the Stock Portfolio Rails Application 29<br />Accessing Our RESTful Application with Flex 39<br />Summary 48<br /> <br />Chapter 4: Using Fluint to Test a Flex with Rails Application 49<br />Using Fluint to Write Your Flex Unit Tests 50<br />The Basics of Testing a Flex Application 51<br />Testing a Cairngorm-Based Application 59<br />Using Fixtures 79<br />Summary 83<br /> <br />Chapter 5: Passing Data with AMF 85<br />What Is AMF? 85<br />Benefits of AMF 86<br />RubyAMF 87<br />A Simple RubyAMF Example 95<br />A RESTful RubyAMF Integration 101<br />Summary 103<br /> <br />Chapter 6: Debugging 105<br />Logging 106<br />Debuggers 110<br />Command Line Debuggers 117<br />Debugging Communication 127<br />Summary 129<br /> <br />Chapter 7: Data Visualization 131<br />Online Analytical Processing (OLAP) 133<br />Advanced DataGrid 144<br />Charting 147<br />Summary 152<br /> <br />Chapter 8: Flex MVC Frameworks 153<br />What Do We Mean by a Framework? 153<br />Roll Your Own 154<br />Cairngorm at a High Level 154<br />PureMVC at a High Level 159<br />Stuff 163<br />Summary 182<br /> <br />Chapter 9: Performance and Optimization 185<br />Flex Performance 185<br />Rails Performance 206<br />Summary 211<br /> <br /><strong>PART II: Cookbook Recipes</strong><br /><br />Chapter 10: Source Control Flex and Rails Projects 215<br />Goal 215<br />Solution 215<br />Ignoring Files in Subversion 215<br />Git 217<br />Discussion 218<br />Summary 219<br /> <br />Chapter 11: Building Flex with Rake 221<br />Goal 221<br />Solution 221<br />Rake Is Your Friend 221<br />The Rakefile 222<br />Summary 225<br /> <br />Chapter 12: Deploying Flex and Rails Applications 227<br />Goal 227<br />Solution 227<br />Capistrano 227<br />Deploying with Capistrano 228<br />Summary 232<br /> <br />Chapter 13: Read the Source! 233<br />Goal 233<br />Solution 233<br />The Beauty of Open Source 233<br />The Rails Source 235<br />Flex Source 238<br />Generated Flex Source 240<br />Summary 243<br /> <br />Chapter 14: Using Observers to Clean Up Code 245<br />Goal 245<br />Solution 245<br />BindingUtils and ChangeWatchers in Flex 245<br />Taking Action on ActiveRecord Lifecycle Events 248<br />Summary 250<br /> <br />Chapter 15: Authenticating 251<br />Goal 251<br />Solution 251<br />Authenticating Users 251<br />Installing restful_authentication 251<br />Summary 257<br /> <br />Chapter 16: Reusing Commands with Prana Sequences 259<br />Goal 259<br />Solution 259<br />Sequences 259<br />Prana’s EventSequence 261<br />Summary 265<br /> <br />Chapter 17: Hierarchical Data with RubyAMF 267<br />Goal 267<br />Solution 267<br />Nested Sets 267<br />Summary 273<br /> <br />Chapter 18: Advanced Data Grid and Awesome Nested Set 275<br />Goal 275<br />Solution 275<br />Overview 275<br />Create the Rails Application and Database 275<br />Creating a Script to Load the Data 276<br />Flex Application 279<br />Adding CRUD 282<br />Summary 287<br /> <br />Chapter 19: Runtime Flex Configuration with Prana 289<br />Goal 289<br />Solution 289<br />IoC, Eh? 289<br />Summary 293<br /> <br />Chapter 20: Server Push with Juggernaut 295<br />Goal 295<br />Solution 295<br />Push Technology 295<br />Juggernaut 295<br />Creating the Rails Messaging Application 297<br />Creating the Flex Messaging Client Application 299<br />Summary 301<br /> <br />Chapter 21: Communicating between Flex and JavaScript 303<br />Goal 303<br />Solution 303<br />Communication between Flex and JavaScript 303<br />Security 303<br />Building the Samples 304<br />ExternalInterface 304<br />SWFObject and Prototype 305<br />ExternalInterface in Action 305<br />Flex-Ajax Bridge in Action 309<br />Summary 311<br /> <br />Chapter 22: File Upload 313<br />Goal 313<br />Solution 313<br />File Upload 313<br />Creating the Rails Application and Installing attachment_fu 315<br />Using Flex’s FileReference Class to Upload<br />One or Several Files 316<br />Using Flex URLLoader Class to Upload a PNG File 318<br />Summary 320<br /> <br />Index 321<br /></pre>Daniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.com3tag:blogger.com,1999:blog-6177337792240027905.post-46965710003007091062008-12-03T21:42:00.000-08:002008-12-03T21:54:27.704-08:00Flexonrails.com will be launched just before Xmas.We received notification that the bound book date (literally, the date the books come off the binding machines at the printer) is 12/19. Books usually arrive in the warehouse about 7-10 days after that. On Amazon the book is scheduled for January 5th. That's pretty exciting even though it has been quite a while since we last touched the book. We where waiting to coordinate this website with the launch of the book and where busy on some other projects using Flex+Rails for me. As you see there is still quite some boilerplate pages on this site which we will clean up shortly as well as publish all the source code from the book and we will try to make this site a great companion for the Flex on Rails book and good resource for all you Flex with Rails questions.<br /><br />Also this site is made with <a href="http://webby.rubyforge.org/">Webby</a>, a cool little content management written in Ruby, and I will soon make a small video about how to use so that my friend Tony can start copyediting some of this content.<br /><br />Come back soon for some good stuff!<br /><br />Enjoy!<br />DanielDaniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.com3tag:blogger.com,1999:blog-6177337792240027905.post-18278592218985259882008-06-26T18:51:00.000-07:002008-06-26T19:24:52.800-07:00Starting FlexOnRails.com RedesignAs you see we are in the middle of reorganizing the design of this blog and the overall content of flexonrails.com. The goal is to have some good content on how to Power your Flex and Rails applications with Ruby On Rails. So I mention 'starting' as it's going to be a several week process as I didn't want to wait that everything is ready and preferred just releasing bits and pieces as times permits. Let me know if you think it's a bad idea :-) and let me know what you want to see in this space, share your experience with Flex and Rails. So stay tuned for some good content...<br /><br />Enjoy!<br />DanielDaniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.com0tag:blogger.com,1999:blog-6177337792240027905.post-43147884173947807132008-05-09T12:49:00.000-07:002008-05-09T13:13:13.926-07:00Welcome to Flex On Rails, your new blog on using AIR and Flex with Rails.Your hosts, Tony and Daniel, will use this blog to talk about everything related to using Adobe AIR and Flex with Ruby On Rails. We are currently writing a book on this subject which should be in pretty good shape around September and will be presenting at the end of this month "Powering AIR apps with Rails" at the RailsConf and are working on a mix Flex/AIR/Rails apps for customers and we would love to use our blog to share some of our findings, thoughts, and experiences on the matter. So welcome, over the next two month we will gradually bring this site to a level we are sure you will enjoy!<br /><br />Daniel and TonyDaniel Wanjahttp://www.blogger.com/profile/16505343517130420145noreply@blogger.com0