SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
Flex and Rails   Tony Hillerson
                  Software Architect

with RubyAMF      EffectiveUI
                  RailsConf
Code and Slides:
http://github.com/thillerson/preso_code/
Sample du Jour: Stuff
Why Flex and Rails?

They Make The
Great Tag Team!
[SKIP INTRO]
What are the Options?
XML
XML is the Default
     Option
# POST /contexts
# POST /contexts.xml
def create
  @context = Context.new(params[:context])
  respond_to do |format|
    if @context.save
      flash[:notice] = 'Context was successfully created.'
      format.html { redirect_to(@context) }
      format.xml {
         render :xml => @context,
         :status => :created, :location => @context }
    else
      format.html { render :action => quot;newquot; }
      format.xml {
         render :xml => @context.errors,
         :status => :unprocessable_entity }
    end
  end
end
JSON

Javascript Object Notation
JSON is in Rails Too
format.json { render :json => @context.to_json }


        http://as3corlib.googlecode.com


   var obj:Object = JSON.decode(jsonString)
AMF

Action Message Format
AMF is the Good Stuff

Buck Thinks it’s Great!
RubyAMF


       http://rubyamf.org
http://rubyamf.googlecode.com
Installing RubyAMF
$ script/plugin install http://rubyamf.googlecode.com/svn/current/rubyamf


  • New File: app/controllers/rubyamf_controller.rb
  • New File: config/rubyamf_config.rb
  • config/initializers/mime_types.rb modified:
     Mime::Type.register quot;application/x-amfquot;, :amf

  • config/routes.rb modified:
    ActionController::Routing::Routes.draw do |map|
        map.rubyamf_gateway 'rubyamf_gateway',
          :controller => 'rubyamf', :action => 'gateway'
    end
Con guring RubyAMF
module RubyAMF
  module Configuration
    ClassMappings.translate_case = true
    ClassMappings.assume_types = false
    ParameterMappings.scaffolding = true
    ClassMappings.register(
      :actionscript => 'Task',
      :ruby          => 'Task',
      :type          => 'active_record',
      #:associations => [quot;contextquot;],
      :attributes    => [quot;idquot;, quot;labelquot;, quot;context_idquot;,
         quot;completed_atquot;, quot;created_atquot;, quot;updated_atquot;])
  end
end
Con guring RubyAMF
ClassMappings.translate_case = false

public var created_at:Date;


ClassMappings.translate_case = true

public var createdAt:Date; // created_at in rails
Con guring RubyAMF
  ClassMappings.assume_types = true

  class Context < ActiveRecord::Base
              matches
   [RemoteClass(alias=quot;Contextquot;)]
   public class Context {

               for free
Con guring RubyAMF
  ClassMappings.assume_types = false

  class Context < ActiveRecord::Base
              matches
   [RemoteClass(alias=quot;Contextquot;)]
   public class Context {

          with registration
  ClassMappings.register(
    :actionscript => 'Context',
    :ruby          => 'Context',
    :type          => 'active_record',
    :attributes    => [quot;idquot;, ...])
Con guring RubyAMF
              ParameterMappings.scaffolding = false

                                       def save
                         becomes
     save(context);                      @context = params[0]


             ParameterMappings.scaffolding = true
                                       def save
save(
                                         @context =
                         becomes
   {context:context}
                                            params[:context]
);
Connecting to Rails via
       RubyAMF
<mx:RemoteObject
    	id=quot;contextsServicequot;
    	destination=quot;rubyamfquot;
    	endpoint=quot;http://localhost:3000/rubyamf_gateway/quot;
    	source=quot;ContextsControllerquot;
    	showBusyCursor=quot;truequot;
/>
public function save(context:Context):void {
	 	 var call:AsyncToken =
          contextsService.save({context:context});
	 	 call.addResponder(responder);
}
Development Work ow
1. Generate and Migrate
$ script/generate rubyamf_scaffold context label:string
class CreateContexts < ActiveRecord::Migration
  def self.up
    create_table :contexts do |t|
      t.string :label
      t.timestamps
    end
  end

  def self.down
    drop_table :contexts
  end
end
$ rake db:migrate
def load_all
  @contexts = Context.find :all

  respond_to do |format|
    format.amf { render :amf => @contexts }
  end
end

def save
  respond_to do |format|
    format.amf do
      if params[:context].save
         render :amf => params[:context]
      else
         render :amf =>
           FaultObject.new(params[:context].errors.join(quot;nquot;))
      end
    end
  end
end
2. Sample Data
work:
  id: 1
  label: Work

home:
  id: 2
  label: Home

anarco_syndicalist_commune_biweekly_meetings:
  id: 3
  label: Anarcho-syndicalist Commune Bi-weekly Meetings
3. Test
class Context < ActiveRecord::Base
  validates_presence_of :label



class ContextTest < ActiveSupport::TestCase
  def test_context_without_label_fails
    non_label_context = Context.new
    assert !(non_label_context.save)
    error_messages = non_label_context.errors.on(:label)
    assert !(error_messages.empty?)
  end
4. Con gure

ClassMappings.register(
  :actionscript => 'Context',
  :ruby          => 'Context',
  :type          => 'active_record',
  #:associations => [quot;tasksquot;],
  :attributes    => [quot;idquot;, quot;labelquot;, quot;created_atquot;, quot;updated_atquot;])
5. Wire
<mx:RemoteObject
    	id=quot;contextsServicequot;
    	destination=quot;rubyamfquot;
    	endpoint=quot;http://localhost:3000/rubyamf_gateway/quot;
    	source=quot;ContextsControllerquot;
    	showBusyCursor=quot;truequot;
/>

<mx:RemoteObject
     id=quot;tasksServicequot;
     destination=quot;rubyamfquot;
    	endpoint=quot;http://localhost:3000/rubyamf_gateway/quot;
    	source=quot;TasksControllerquot;
    	showBusyCursor=quot;truequot;
/>
5. Wire
public function loadAll():void {
	 var call:AsyncToken = service.load_all();
	 call.addResponder(responder);
}

public function save(context:Context):void {
	 var call:AsyncToken =
       service.save({context:context});
	 call.addResponder(responder);
}

public function destroy(context:Context):void {
	 var call:AsyncToken =
       service.destroy({id:context.id});
	 call.addResponder(responder);
}
5. Wire
public function execute(event:CairngormEvent):void {
	 var evt:SaveContextEvent = event as SaveContextEvent;
	 var delegate:ContextsDelegate = new ContextsDelegate(this);
	 delegate.save(evt.context);
}

public function result(data:Object):void {
	 var result:ResultEvent = data as ResultEvent;
	 var context:Context = result.result as Context;
  ...
}
X. Rinse and Repeat
The Future
Gem
Plugin + Gem
 C Extension
Gem
   Plugin
C Extension
An Impassioned Plea
Resources:

http://rubyamf.googlecode.com
http://groups.google.com/group/rubyamf
http://github.com/thillerson/rubyamf
Your
                              Bob
                                        Father




                                         You




     Thanks!
     Tony Hillerson
     http://slideshare.com/thillerson
     http://github.com/thillerson
     http://thillerson.blogspot.com
     http://effectiveui.com

     Twitter: thillerson
     Brightkite: thillerson




39

Weitere ähnliche Inhalte

Was ist angesagt?

Lightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientLightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientAdam Wiggins
 
Javascript asynchronous
Javascript asynchronousJavascript asynchronous
Javascript asynchronouskang taehun
 
Tasks: you gotta know how to run them
Tasks: you gotta know how to run themTasks: you gotta know how to run them
Tasks: you gotta know how to run themFilipe Ximenes
 
Introduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDBIntroduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDBAdrien Joly
 
[Quase] Tudo que você precisa saber sobre tarefas assíncronas
[Quase] Tudo que você precisa saber sobre  tarefas assíncronas[Quase] Tudo que você precisa saber sobre  tarefas assíncronas
[Quase] Tudo que você precisa saber sobre tarefas assíncronasFilipe Ximenes
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutVic Metcalfe
 
Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...
Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...
Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...Alberto Perdomo
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbJuan Maiz
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perldeepfountainconsulting
 
エラー時にログに出力する情報と画面に表示する情報を分ける #LaravelTokyo
エラー時にログに出力する情報と画面に表示する情報を分ける #LaravelTokyoエラー時にログに出力する情報と画面に表示する情報を分ける #LaravelTokyo
エラー時にログに出力する情報と画面に表示する情報を分ける #LaravelTokyoShohei Okada
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous Shmuel Fomberg
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpmsom_nangia
 
Артем Яворский "Compile like it's 2017"
Артем Яворский "Compile like it's 2017"Артем Яворский "Compile like it's 2017"
Артем Яворский "Compile like it's 2017"Fwdays
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)xSawyer
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
 
Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Benny Siegert
 
Any event intro
Any event introAny event intro
Any event introqiang
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkJeremy Kendall
 

Was ist angesagt? (19)

Lightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClientLightweight Webservices with Sinatra and RestClient
Lightweight Webservices with Sinatra and RestClient
 
Javascript asynchronous
Javascript asynchronousJavascript asynchronous
Javascript asynchronous
 
Tasks: you gotta know how to run them
Tasks: you gotta know how to run themTasks: you gotta know how to run them
Tasks: you gotta know how to run them
 
node ffi
node ffinode ffi
node ffi
 
Introduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDBIntroduction to asynchronous DB access using Node.js and MongoDB
Introduction to asynchronous DB access using Node.js and MongoDB
 
[Quase] Tudo que você precisa saber sobre tarefas assíncronas
[Quase] Tudo que você precisa saber sobre  tarefas assíncronas[Quase] Tudo que você precisa saber sobre  tarefas assíncronas
[Quase] Tudo que você precisa saber sobre tarefas assíncronas
 
Slim RedBeanPHP and Knockout
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
 
Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...
Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...
Strangers In The Night: Ruby, Rack y Sinatra - Herramientas potentes para con...
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRb
 
Asynchronous programming patterns in Perl
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perl
 
エラー時にログに出力する情報と画面に表示する情報を分ける #LaravelTokyo
エラー時にログに出力する情報と画面に表示する情報を分ける #LaravelTokyoエラー時にログに出力する情報と画面に表示する情報を分ける #LaravelTokyo
エラー時にログに出力する情報と画面に表示する情報を分ける #LaravelTokyo
 
Perl: Coro asynchronous
Perl: Coro asynchronous Perl: Coro asynchronous
Perl: Coro asynchronous
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpm
 
Артем Яворский "Compile like it's 2017"
Артем Яворский "Compile like it's 2017"Артем Яворский "Compile like it's 2017"
Артем Яворский "Compile like it's 2017"
 
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)
 
Perl web frameworks
Perl web frameworksPerl web frameworks
Perl web frameworks
 
Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]Build Systems with autoconf, automake and libtool [updated]
Build Systems with autoconf, automake and libtool [updated]
 
Any event intro
Any event introAny event intro
Any event intro
 
Keeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro framework
 

Andere mochten auch

The Information Advantage - Information Access in Tomorrow's Enterprise
The Information Advantage - Information Access in Tomorrow's EnterpriseThe Information Advantage - Information Access in Tomorrow's Enterprise
The Information Advantage - Information Access in Tomorrow's EnterpriseElizabeth Lupfer
 
Top 10 Clues That Your Presentation Is Too Long
Top 10 Clues That Your Presentation Is Too LongTop 10 Clues That Your Presentation Is Too Long
Top 10 Clues That Your Presentation Is Too LongSusan Joy Schleef
 
Mercer: What's Working Research on Employee Engagement
Mercer: What's Working Research on Employee EngagementMercer: What's Working Research on Employee Engagement
Mercer: What's Working Research on Employee EngagementElizabeth Lupfer
 
Beyond Employee Engagement | @dalecarnegie
Beyond Employee Engagement | @dalecarnegieBeyond Employee Engagement | @dalecarnegie
Beyond Employee Engagement | @dalecarnegieElizabeth Lupfer
 
Midwinter Holidays: Rebirth of Light
Midwinter Holidays:  Rebirth of LightMidwinter Holidays:  Rebirth of Light
Midwinter Holidays: Rebirth of LightSusan Joy Schleef
 
MRV Folder Fortune / Fortaleza - CE
MRV Folder Fortune / Fortaleza - CEMRV Folder Fortune / Fortaleza - CE
MRV Folder Fortune / Fortaleza - CEMRV Engenharia
 
tamtan company profile
tamtan company profiletamtan company profile
tamtan company profilesandy sandy
 
Information Extraction and Linked Data Cloud
Information Extraction and Linked Data CloudInformation Extraction and Linked Data Cloud
Information Extraction and Linked Data CloudDhaval Thakker
 
The Brand Train - Branding on the move
The Brand Train - Branding on the moveThe Brand Train - Branding on the move
The Brand Train - Branding on the moveUmesh R. Sonawane
 
ICEIM Conference, Durban, SA 2014 - Sudeep Krishnan, IIM Ahmedabad
ICEIM Conference, Durban, SA 2014 - Sudeep Krishnan, IIM AhmedabadICEIM Conference, Durban, SA 2014 - Sudeep Krishnan, IIM Ahmedabad
ICEIM Conference, Durban, SA 2014 - Sudeep Krishnan, IIM AhmedabadSudeep Krishnan
 
Grafittis, Lenguaje Urbano
Grafittis, Lenguaje UrbanoGrafittis, Lenguaje Urbano
Grafittis, Lenguaje Urbanonico552
 

Andere mochten auch (20)

Resurfacing
ResurfacingResurfacing
Resurfacing
 
The Information Advantage - Information Access in Tomorrow's Enterprise
The Information Advantage - Information Access in Tomorrow's EnterpriseThe Information Advantage - Information Access in Tomorrow's Enterprise
The Information Advantage - Information Access in Tomorrow's Enterprise
 
Top 10 Clues That Your Presentation Is Too Long
Top 10 Clues That Your Presentation Is Too LongTop 10 Clues That Your Presentation Is Too Long
Top 10 Clues That Your Presentation Is Too Long
 
Mercer: What's Working Research on Employee Engagement
Mercer: What's Working Research on Employee EngagementMercer: What's Working Research on Employee Engagement
Mercer: What's Working Research on Employee Engagement
 
Beyond Employee Engagement | @dalecarnegie
Beyond Employee Engagement | @dalecarnegieBeyond Employee Engagement | @dalecarnegie
Beyond Employee Engagement | @dalecarnegie
 
Focas bebês - Focas babies
Focas bebês - Focas babiesFocas bebês - Focas babies
Focas bebês - Focas babies
 
The Power of Peace
The Power of PeaceThe Power of Peace
The Power of Peace
 
How To Present
How To PresentHow To Present
How To Present
 
Global Warming
Global WarmingGlobal Warming
Global Warming
 
Relationships 2.0
Relationships 2.0Relationships 2.0
Relationships 2.0
 
Midwinter Holidays: Rebirth of Light
Midwinter Holidays:  Rebirth of LightMidwinter Holidays:  Rebirth of Light
Midwinter Holidays: Rebirth of Light
 
MRV Folder Fortune / Fortaleza - CE
MRV Folder Fortune / Fortaleza - CEMRV Folder Fortune / Fortaleza - CE
MRV Folder Fortune / Fortaleza - CE
 
Module05
Module05Module05
Module05
 
tamtan company profile
tamtan company profiletamtan company profile
tamtan company profile
 
Information Extraction and Linked Data Cloud
Information Extraction and Linked Data CloudInformation Extraction and Linked Data Cloud
Information Extraction and Linked Data Cloud
 
The Brand Train - Branding on the move
The Brand Train - Branding on the moveThe Brand Train - Branding on the move
The Brand Train - Branding on the move
 
ICEIM Conference, Durban, SA 2014 - Sudeep Krishnan, IIM Ahmedabad
ICEIM Conference, Durban, SA 2014 - Sudeep Krishnan, IIM AhmedabadICEIM Conference, Durban, SA 2014 - Sudeep Krishnan, IIM Ahmedabad
ICEIM Conference, Durban, SA 2014 - Sudeep Krishnan, IIM Ahmedabad
 
Module03
Module03Module03
Module03
 
Grafittis, Lenguaje Urbano
Grafittis, Lenguaje UrbanoGrafittis, Lenguaje Urbano
Grafittis, Lenguaje Urbano
 
Holiday Greetings
Holiday GreetingsHoliday Greetings
Holiday Greetings
 

Ähnlich wie Flex With Rubyamf

All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkBen Scofield
 
Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous MerbMatt Todd
 
Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009bturnbull
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2Hugo Hamon
 
And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportBen Scofield
 
Rush, a shell that will yield to you
Rush, a shell that will yield to youRush, a shell that will yield to you
Rush, a shell that will yield to youguestdd9d06
 
Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Guillaume Laforge
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - IntroductionVagmi Mudumbai
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxbobmcwhirter
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineAndy McKay
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsMike Subelsky
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Racksickill
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialYi-Ting Cheng
 
浜松Rails3道場 其の四 View編
浜松Rails3道場 其の四 View編浜松Rails3道場 其の四 View編
浜松Rails3道場 其の四 View編Masakuni Kato
 

Ähnlich wie Flex With Rubyamf (20)

All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous Merb
 
Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009Rails 2.3 and Rack - NHRuby Feb 2009
Rails 2.3 and Rack - NHRuby Feb 2009
 
Red5 - PHUG Workshops
Red5 - PHUG WorkshopsRed5 - PHUG Workshops
Red5 - PHUG Workshops
 
Speed up your developments with Symfony2
Speed up your developments with Symfony2Speed up your developments with Symfony2
Speed up your developments with Symfony2
 
And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack Support
 
Rush, a shell that will yield to you
Rush, a shell that will yield to youRush, a shell that will yield to you
Rush, a shell that will yield to you
 
Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007Grails Introduction - IJTC 2007
Grails Introduction - IJTC 2007
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
Ruby on Rails - Introduction
Ruby on Rails - IntroductionRuby on Rails - Introduction
Ruby on Rails - Introduction
 
Complex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBoxComplex Made Simple: Sleep Better with TorqueBox
Complex Made Simple: Sleep Better with TorqueBox
 
Cross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App EngineCross Domain Web
Mashups with JQuery and Google App Engine
Cross Domain Web
Mashups with JQuery and Google App Engine
 
Jicc teaching rails
Jicc teaching railsJicc teaching rails
Jicc teaching rails
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
 
浜松Rails3道場 其の四 View編
浜松Rails3道場 其の四 View編浜松Rails3道場 其の四 View編
浜松Rails3道場 其の四 View編
 
ES6: The Awesome Parts
ES6: The Awesome PartsES6: The Awesome Parts
ES6: The Awesome Parts
 
Sprockets
SprocketsSprockets
Sprockets
 

Mehr von Tony Hillerson

Totally Build Apps for Free! (not really)
Totally Build Apps for Free! (not really)Totally Build Apps for Free! (not really)
Totally Build Apps for Free! (not really)Tony Hillerson
 
Dynamic Sound for Android
Dynamic Sound for AndroidDynamic Sound for Android
Dynamic Sound for AndroidTony Hillerson
 
Git for Android Developers
Git for Android DevelopersGit for Android Developers
Git for Android DevelopersTony Hillerson
 
Designing an Android App from Idea to Market
Designing an Android App from Idea to MarketDesigning an Android App from Idea to Market
Designing an Android App from Idea to MarketTony Hillerson
 
SCM for Android Developers Using Git
SCM for Android Developers Using GitSCM for Android Developers Using Git
SCM for Android Developers Using GitTony Hillerson
 
First Android Experience
First Android ExperienceFirst Android Experience
First Android ExperienceTony Hillerson
 
iPhone Persistence For Mere Mortals
iPhone Persistence For Mere MortalsiPhone Persistence For Mere Mortals
iPhone Persistence For Mere MortalsTony Hillerson
 
Flex Framework Smackdown
Flex Framework SmackdownFlex Framework Smackdown
Flex Framework SmackdownTony Hillerson
 

Mehr von Tony Hillerson (11)

Totally Build Apps for Free! (not really)
Totally Build Apps for Free! (not really)Totally Build Apps for Free! (not really)
Totally Build Apps for Free! (not really)
 
Working with Git
Working with GitWorking with Git
Working with Git
 
Dynamic Sound for Android
Dynamic Sound for AndroidDynamic Sound for Android
Dynamic Sound for Android
 
Git for Android Developers
Git for Android DevelopersGit for Android Developers
Git for Android Developers
 
Designing an Android App from Idea to Market
Designing an Android App from Idea to MarketDesigning an Android App from Idea to Market
Designing an Android App from Idea to Market
 
Rails on HBase
Rails on HBaseRails on HBase
Rails on HBase
 
SCM for Android Developers Using Git
SCM for Android Developers Using GitSCM for Android Developers Using Git
SCM for Android Developers Using Git
 
First Android Experience
First Android ExperienceFirst Android Experience
First Android Experience
 
iPhone Persistence For Mere Mortals
iPhone Persistence For Mere MortalsiPhone Persistence For Mere Mortals
iPhone Persistence For Mere Mortals
 
Flex Framework Smackdown
Flex Framework SmackdownFlex Framework Smackdown
Flex Framework Smackdown
 
Flex And Rails
Flex And RailsFlex And Rails
Flex And Rails
 

Kürzlich hochgeladen

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Kürzlich hochgeladen (20)

A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

Flex With Rubyamf

  • 1. Flex and Rails Tony Hillerson Software Architect with RubyAMF EffectiveUI RailsConf
  • 4.
  • 5. Why Flex and Rails? They Make The Great Tag Team!
  • 7. What are the Options?
  • 8. XML
  • 9. XML is the Default Option
  • 10. # POST /contexts # POST /contexts.xml def create @context = Context.new(params[:context]) respond_to do |format| if @context.save flash[:notice] = 'Context was successfully created.' format.html { redirect_to(@context) } format.xml { render :xml => @context, :status => :created, :location => @context } else format.html { render :action => quot;newquot; } format.xml { render :xml => @context.errors, :status => :unprocessable_entity } end end end
  • 12. JSON is in Rails Too format.json { render :json => @context.to_json } http://as3corlib.googlecode.com var obj:Object = JSON.decode(jsonString)
  • 14. AMF is the Good Stuff Buck Thinks it’s Great!
  • 15. RubyAMF http://rubyamf.org http://rubyamf.googlecode.com
  • 16. Installing RubyAMF $ script/plugin install http://rubyamf.googlecode.com/svn/current/rubyamf • New File: app/controllers/rubyamf_controller.rb • New File: config/rubyamf_config.rb • config/initializers/mime_types.rb modified: Mime::Type.register quot;application/x-amfquot;, :amf • config/routes.rb modified: ActionController::Routing::Routes.draw do |map| map.rubyamf_gateway 'rubyamf_gateway', :controller => 'rubyamf', :action => 'gateway' end
  • 17. Con guring RubyAMF module RubyAMF module Configuration ClassMappings.translate_case = true ClassMappings.assume_types = false ParameterMappings.scaffolding = true ClassMappings.register( :actionscript => 'Task', :ruby => 'Task', :type => 'active_record', #:associations => [quot;contextquot;], :attributes => [quot;idquot;, quot;labelquot;, quot;context_idquot;, quot;completed_atquot;, quot;created_atquot;, quot;updated_atquot;]) end end
  • 18. Con guring RubyAMF ClassMappings.translate_case = false public var created_at:Date; ClassMappings.translate_case = true public var createdAt:Date; // created_at in rails
  • 19. Con guring RubyAMF ClassMappings.assume_types = true class Context < ActiveRecord::Base matches [RemoteClass(alias=quot;Contextquot;)] public class Context { for free
  • 20. Con guring RubyAMF ClassMappings.assume_types = false class Context < ActiveRecord::Base matches [RemoteClass(alias=quot;Contextquot;)] public class Context { with registration ClassMappings.register( :actionscript => 'Context', :ruby => 'Context', :type => 'active_record', :attributes => [quot;idquot;, ...])
  • 21. Con guring RubyAMF ParameterMappings.scaffolding = false def save becomes save(context); @context = params[0] ParameterMappings.scaffolding = true def save save( @context = becomes {context:context} params[:context] );
  • 22. Connecting to Rails via RubyAMF <mx:RemoteObject id=quot;contextsServicequot; destination=quot;rubyamfquot; endpoint=quot;http://localhost:3000/rubyamf_gateway/quot; source=quot;ContextsControllerquot; showBusyCursor=quot;truequot; /> public function save(context:Context):void { var call:AsyncToken = contextsService.save({context:context}); call.addResponder(responder); }
  • 24. 1. Generate and Migrate $ script/generate rubyamf_scaffold context label:string class CreateContexts < ActiveRecord::Migration def self.up create_table :contexts do |t| t.string :label t.timestamps end end def self.down drop_table :contexts end end $ rake db:migrate
  • 25. def load_all @contexts = Context.find :all respond_to do |format| format.amf { render :amf => @contexts } end end def save respond_to do |format| format.amf do if params[:context].save render :amf => params[:context] else render :amf => FaultObject.new(params[:context].errors.join(quot;nquot;)) end end end end
  • 26. 2. Sample Data work: id: 1 label: Work home: id: 2 label: Home anarco_syndicalist_commune_biweekly_meetings: id: 3 label: Anarcho-syndicalist Commune Bi-weekly Meetings
  • 27. 3. Test class Context < ActiveRecord::Base validates_presence_of :label class ContextTest < ActiveSupport::TestCase def test_context_without_label_fails non_label_context = Context.new assert !(non_label_context.save) error_messages = non_label_context.errors.on(:label) assert !(error_messages.empty?) end
  • 28. 4. Con gure ClassMappings.register( :actionscript => 'Context', :ruby => 'Context', :type => 'active_record', #:associations => [quot;tasksquot;], :attributes => [quot;idquot;, quot;labelquot;, quot;created_atquot;, quot;updated_atquot;])
  • 29. 5. Wire <mx:RemoteObject id=quot;contextsServicequot; destination=quot;rubyamfquot; endpoint=quot;http://localhost:3000/rubyamf_gateway/quot; source=quot;ContextsControllerquot; showBusyCursor=quot;truequot; /> <mx:RemoteObject id=quot;tasksServicequot; destination=quot;rubyamfquot; endpoint=quot;http://localhost:3000/rubyamf_gateway/quot; source=quot;TasksControllerquot; showBusyCursor=quot;truequot; />
  • 30. 5. Wire public function loadAll():void { var call:AsyncToken = service.load_all(); call.addResponder(responder); } public function save(context:Context):void { var call:AsyncToken = service.save({context:context}); call.addResponder(responder); } public function destroy(context:Context):void { var call:AsyncToken = service.destroy({id:context.id}); call.addResponder(responder); }
  • 31. 5. Wire public function execute(event:CairngormEvent):void { var evt:SaveContextEvent = event as SaveContextEvent; var delegate:ContextsDelegate = new ContextsDelegate(this); delegate.save(evt.context); } public function result(data:Object):void { var result:ResultEvent = data as ResultEvent; var context:Context = result.result as Context; ... }
  • 32. X. Rinse and Repeat
  • 34. Gem Plugin + Gem C Extension
  • 35. Gem Plugin C Extension
  • 36.
  • 39. Your Bob Father You Thanks! Tony Hillerson http://slideshare.com/thillerson http://github.com/thillerson http://thillerson.blogspot.com http://effectiveui.com Twitter: thillerson Brightkite: thillerson 39