SlideShare ist ein Scribd-Unternehmen logo
1 von 31
Downloaden Sie, um offline zu lesen
Talk	
  Directly	
  with	
  Ac#veRecord	
  	
  
using	
  Ext.Direct	
  and	
  Rack	
  Middleware	
  




           Stone	
  Gao,	
  Ekohe	
  




                     Stone	
  Gao,	
  KungfuRails	
  
                    (stones.gao@gmail.com)	
  
Outline	
  
•  Intro	
  to	
  Ext	
  Js	
  
•  The	
  Problem	
  
•  The	
  SoluDon	
  :	
  Ext.Direct	
  	
  
•  Intro	
  to	
  Rack	
  Middleware	
  
•  Ac#veDirect	
  (an	
  Experimental	
  ImplementaDon	
  
   of	
  Ext.Direct,	
  yet	
  )	
  
•  What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  (Examples)	
  
•  Q	
  &	
  A	
  
                            Stone	
  Gao,	
  KungfuRails	
  
                           (stones.gao@gmail.com)	
  
Intro	
  to	
  Ext	
  Js	
  
Ext	
  JS	
  is	
  a	
  cross-­‐browser	
  JavaScript	
  library	
  for	
  building	
  rich	
  
internet	
  applicaDons.	
  

•  igh	
  performance,	
  customizable	
  UI	
  widgets,	
  Ajax	
  
      H
• ntuiDve,	
  easy	
  to	
  use	
  API	
  
      I
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  (hTp://www.extjs.com)	
  	
  




                                                                                                                            Stone	
  Gao,	
  KungfuRails	
  
                                                                                                                           (stones.gao@gmail.com)	
  
The	
  Problem	
  




     Stone	
  Gao,	
  KungfuRails	
  
    (stones.gao@gmail.com)	
  
Ajax	
  Calls	
  
Foo.js	
  
…….	
  

Ext.Ajax.request({	
                                                                             Bar.js	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  url:	
  ("/foo?format=json"),	
  
                                                                                      ……	
                                                                                       Baz.js	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  method:	
  "POST",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  jsonData:	
  	
  payLoad,	
                                                                                                         ……	
  
                                                                                      Ext.Ajax.request({	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  success:	
  this..success,	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  url:	
  (”/bar?format=json"),	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  failure:	
  this.failure,	
                                                                                                         Ext.Ajax.request({	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  method:	
  ”GET",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  headers:	
  {	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  jsonData:	
  	
  payLoad,	
                   	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  url:	
  (”/baz?format=json"),	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  'accepts':	
  'applicaDon/json'	
     	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  success:	
  this..success,	
                  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  method:	
  "POST",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  failure:	
  this.failure,	
                   	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  jsonData:	
  	
  payLoad,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  scope	
  :	
  this	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  headers:	
  {	
                               	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  success:	
  this..success,	
  
	
  	
  	
  	
  	
  	
  	
  	
  });	
                                                                                                                                       	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  failure:	
  this.failure,	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  'accepts':	
  'applicaDon/json'	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
                                          	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  headers:	
  {	
  
……	
                                                                                  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  scope	
  :	
  this	
                          	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  'accepts':	
  'applicaDon/json'	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  });	
                                                 	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  
                                                                                                                                                                            	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  scope	
  :	
  this	
  
                                                                                      ……	
                                                                                  	
  	
  	
  	
  	
  	
  	
  	
  });	
  

                                                                                                                                                                            ……	
  




                                                                                               Stone	
  Gao,	
  KungfuRails	
  
                                                                                              (stones.gao@gmail.com)	
  
Ajax	
  Calls	
  
Foo.js	
  
…….	
  

Ext.Ajax.request({	
                                                                             Bar.js	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  url:	
  ("/foo?format=json"),	
  
                                                                                      ……	
                                                                                       Baz.js	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  method:	
  "POST",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  jsonData:	
  	
  payLoad,	
                                                                                                         ……	
  
                                                                                      Ext.Ajax.request({	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  success:	
  this..success,	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  url:	
  (”/bar?format=json"),	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  failure:	
  this.failure,	
                                                                                                         Ext.Ajax.request({	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  method:	
  ”GET",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  headers:	
  {	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  jsonData:	
  	
  payLoad,	
                   	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  url:	
  (”/baz?format=json"),	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  'accepts':	
  'applicaDon/json'	
     	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  success:	
  this..success,	
                  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  method:	
  "POST",	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  failure:	
  this.failure,	
                   	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  jsonData:	
  	
  payLoad,	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  scope	
  :	
  this	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  headers:	
  {	
                               	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  success:	
  this..success,	
  
	
  	
  	
  	
  	
  	
  	
  	
  });	
                                                                                                                                       	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  failure:	
  this.failure,	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  'accepts':	
  'applicaDon/json'	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
                                          	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  headers:	
  {	
  
……	
                                                                                  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  scope	
  :	
  this	
                          	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  'accepts':	
  'applicaDon/json'	
  
                                                                                      	
  	
  	
  	
  	
  	
  	
  	
  });	
                                                 	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  
                                                                                                                                                                            	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  scope	
  :	
  this	
  
                                                                                      ……	
                                                                                  	
  	
  	
  	
  	
  	
  	
  	
  });	
  

                                                                                                                                                                            ……	
  




                                                                                               Stone	
  Gao,	
  KungfuRails	
  
                                                                                              (stones.gao@gmail.com)	
  
The	
  SoluDon	
  




    Stone	
  Gao,	
  KungfuRails	
  
   (stones.gao@gmail.com)	
  
The	
  SoluDon	
  

Ext.Direct	
  
 Ext.Direct	
  is	
  a	
  pladorm	
  and	
  language	
  agnosDc	
  technology	
  to	
  
 remote	
  server-­‐side	
  methods	
  to	
  the	
  client-­‐side.	
  Furthermore,	
  
 Ext.Direct	
  allows	
  for	
  seamless	
  communicaDon	
  between	
  the	
  
 client-­‐side	
  of	
  an	
  Ext	
  applicaDon	
  and	
  any	
  server-­‐side	
  pladorm.	
  

 (hTp://www.extjs.com/products/extjs/direct.php)	
  	
  

You	
  can	
  write	
  the	
  following	
  code	
  in	
  javascript	
  :	
  	
  
App.models.Category.foo()	
  
App.models.Category.bar()	
  
App.models.Category.create(	
  {	
  name	
  :	
  ‘ruby’	
  }	
  	
  )	
  
App.models.Category.update(	
  1,	
  {	
  name	
  :	
  ‘ruby’	
  }	
  	
  )	
  
App.models.Category.delete(1)	
  
                                          Stone	
  Gao,	
  KungfuRails	
  
                                         (stones.gao@gmail.com)	
  
Intro	
  to	
  Rack	
  Middleware	
  	
  
                                                       Middleware	
                    App	
  



                HTTP	
  Request	
  




  HTTP	
  
  Client	
                             log	
                auth	
         cache	
  
(browser)	
     HTTP	
  Response	
  




                                        Stone	
  Gao,	
  KungfuRails	
  
                                       (stones.gao@gmail.com)	
  
Intro	
  to	
  Rack	
  Middleware	
  	
  

>>	
  	
  ps	
  aux	
  |	
  grep	
  ruby	
  |	
  wc	
  –l	
  
3	
  

Rack	
  Middleware	
  is	
  Pipeline	
  for	
  HTTP	
  Req	
  Processing!	
  	
  
                                                                                                                                              Middleware	
                 App	
  


 The	
  Unix	
  Philosophy	
  :	
  	
  
                                                                                                             HTTP	
  Request	
  
 Rack	
  Middleware	
  is	
  	
  
 Chainable	
                                                                                   HTTP	
  

 and	
                                                                                         Client	
  
                                                                                             (browser)	
  
                                                                                                             HTTP	
  Response	
  
                                                                                                                                    log	
        auth	
        cache	
  



 Composable	
  like	
  Unix	
  Pipelines	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  


                                                                          Stone	
  Gao,	
  KungfuRails	
  
                                                                         (stones.gao@gmail.com)	
  
Intro	
  to	
  Rack	
  Middleware	
  	
  

Conven#on	
  :	
  app.call(env)	
  


lambda	
  {	
  |env|	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #Rack	
  Environment	
  variables	
  	
  
	
  	
  [	
  	
  200,	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #Status	
  Code	
  	
  
	
  	
  	
  	
  	
  {‘Content-­‐Type’	
  =>	
  ‘text/plain’},	
  	
  	
  	
  	
  	
  #Headers	
  	
  
	
  	
  	
  	
  	
  	
  [‘Hello	
  World!’]	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  #Reponse	
  Body	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  
	
  	
  ]	
  
}	
  	
  




                                                                                                                Stone	
  Gao,	
  KungfuRails	
  
                                                                                                               (stones.gao@gmail.com)	
  
Ac#veDirect	
  (an	
  Experimental	
  ImplementaDon	
  of	
  Ext.Direct,	
  yet	
  )	
  
Talk	
  Directly	
  with	
  Ac#veRecord	
  using	
  Ext.Direct	
  and	
  Rack	
  Middleware	
  




                                         Stone	
  Gao,	
  KungfuRails	
  
                                        (stones.gao@gmail.com)	
  
Ac#veDirect	
  (an	
  Experimental	
  ImplementaDon	
  of	
  Ext.Direct,	
  yet	
  )	
  
 Talk	
  Directly	
  with	
  Ac#veRecord	
  using	
  Ext.Direct	
  and	
  Rack	
  Middleware	
  
                                                                                       Method	
  
                                                                                     Dispatching	
  


                                             AcDveDirect::Router	
  



  Ext.Direct	
  	
  



                                                AcDveDirect::Api	
  


           Server-­‐side	
                                                                         App	
  
         methods	
  configs	
                       Rack	
  Middleware	
  

                                           Stone	
  Gao,	
  KungfuRails	
  
                                          (stones.gao@gmail.com)	
  
Ac#veDirect	
  (an	
  Experimental	
  ImplementaDon	
  of	
  Ext.Direct,	
  yet	
  )	
  
   How	
  Ac#veDirect::Api	
  works	
  	
  

                                          App.REMOTING_API	
  =	
  {	
  
                                          	
  	
  	
  	
  "ac#ons":	
  {	
  
                                          	
  	
  	
  	
  	
  	
  	
  	
  "Category":	
  [	
  
                                          	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  
                                          	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "name":	
  "all",	
  
                                          	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "len":	
  1	
  
GET	
  /direct_api	
                      	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  },	
  
                                          	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  {	
  
                                          	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "name":	
  "update_all",	
  
                                          	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  "len":	
  2	
  
                                          	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  }	
  
                                          	
  	
  	
  	
  	
  	
  	
  	
  ]	
  
                                          	
  	
  	
  	
  },	
  
                                          	
  	
  	
  	
  "namespace":	
  "App.models",	
  
                                          	
  	
  	
  	
  "url":	
  "/direct_router",	
  
                                          	
  	
  	
  	
  "type":	
  "remo#ng"	
  
                                          };	
  

                                     Stone	
  Gao,	
  KungfuRails	
  
                                    (stones.gao@gmail.com)	
  
Ac#veDirect	
  (an	
  Experimental	
  ImplementaDon	
  of	
  Ext.Direct,	
  yet	
  )	
  
How	
  Ac#veDirect::Router	
  works	
  

                               App.models.Category.all()	
  


POST	
  /direct_router	
  	
  	
  	
  	
  {"ac#on":"Category","method":"all","data":[],"type":"rpc","#d":3}	
  

                                                                                                   Ac#veDirect::Router	
  




                Category.send	
  :all	
  
                                              Stone	
  Gao,	
  KungfuRails	
  
                                             (stones.gao@gmail.com)	
  
Ac#veDirect	
  -­‐	
  ConfiguraDon	
  
•  Middleware	
  configuraDons	
  (environment.rb)	
  
	
  	
  	
  	
  	
  config.middleware.use	
  'Ac#veDirect::Router',	
  '/direct_router'	
  
	
  	
  	
  	
  	
  config.middleware.use	
  'Ac#veDirect::Api',	
  '/direct_api',	
  '/direct_router’	
  




•  Method	
  configuraDons	
  	
  
	
  	
  	
  	
  	
  	
  <script	
  type="text/javascript"	
  src=”/javascripts/ext/adapter/ext/ext-­‐base.js"></script>	
  
	
  	
  	
  	
  	
  	
  <script	
  type=“text/javascript”	
  src=”/javascripts/ext/ext-­‐all-­‐debug.js"></script>	
  
	
  	
  	
  	
  	
  	
  <script	
  type=“text/javascript”	
  src=”/direct_api"></script>	
  

	
  	
  	
  	
  	
  	
  Ext.Direct.addProvider(App.REMOTING_API);	
  




                                                        Stone	
  Gao,	
  KungfuRails	
  
                                                       (stones.gao@gmail.com)	
  
Ac#veDirect	
  -­‐	
  ConfiguraDon	
  
•  Model	
  configuraDons	
  	
  
class	
  Category	
  <	
  AcDveRecord::Base	
  
	
  	
  	
  	
  acts_as_nested_set	
  
	
  	
  	
  	
  has_many	
  :books	
  
	
  	
  	
  	
  acts_as_direct	
  	
  :root_nodes	
  =>	
  0,	
  :create_new_cat	
  =>	
  {:len	
  =>	
  1,	
  :formHandler	
  =>	
  true}	
  

	
  	
  	
  	
  def	
  root_nodes	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  ……	
  
	
  	
  	
  	
  end	
  	
  
	
  	
  	
  	
  def	
  create_new_cat(params)	
  	
                                           Custom	
  remotable	
  
	
  	
  	
  	
  	
  	
  	
  	
  	
  ……	
                                                          methods	
  
	
  	
  	
  	
  end	
  
end	
  	
  

                                                           Stone	
  Gao,	
  KungfuRails	
  
                                                          (stones.gao@gmail.com)	
  
What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  	
  	
  

             CRUD	
  Default	
  Remotable	
  Methods	
  




            Custom	
  Remotable	
  Methods	
  



                        Stone	
  Gao,	
  KungfuRails	
  
                       (stones.gao@gmail.com)	
  
What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  (examples)	
  	
  	
  


App.models.Category.create(	
  {	
  name	
  :	
  ‘ruby’	
  }	
  	
  )	
  




                                                   Stone	
  Gao,	
  KungfuRails	
  
                                                  (stones.gao@gmail.com)	
  
What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  (examples)	
  	
  	
  


App.models.Category.update(2,	
  	
  {	
  name	
  :	
  ‘ruby	
  books’	
  }	
  )	
  




                                                Stone	
  Gao,	
  KungfuRails	
  
                                               (stones.gao@gmail.com)	
  
What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  (examples)	
  	
  


App.models.Category.update_all({	
  name	
  :	
  ‘ruby	
  books’	
  },	
  	
  “	
  name	
  LIKE	
  ‘%ruby%’	
  ”	
  )	
  




                                               Stone	
  Gao,	
  KungfuRails	
  
                                              (stones.gao@gmail.com)	
  
What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  (examples)	
  	
  

App.models.Category.all()	
  




                                 Stone	
  Gao,	
  KungfuRails	
  
                                (stones.gao@gmail.com)	
  
What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  (examples)	
  	
  


App.models.Category.find(	
  2	
  )	
  




                                          Stone	
  Gao,	
  KungfuRails	
  
                                         (stones.gao@gmail.com)	
  
What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  (examples)	
  	
  


App.models.Category.find_every(	
  {	
  condi#ons	
  :	
  “name	
  LIKE	
  ‘%java%’	
  “	
  }	
  )	
  




                                             Stone	
  Gao,	
  KungfuRails	
  
                                            (stones.gao@gmail.com)	
  
What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  (examples)	
  	
  


App.models.Category.exists(	
  [“	
  name	
  LIKE	
  ?	
  “,	
  	
  ‘%java%’	
  ]	
  )	
  




                                                  Stone	
  Gao,	
  KungfuRails	
  
                                                 (stones.gao@gmail.com)	
  
What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  (examples)	
  	
  




                           Stone	
  Gao,	
  KungfuRails	
  
                          (stones.gao@gmail.com)	
  
What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  (examples)	
  	
  


App.models.Category.count()	
  




                                   Stone	
  Gao,	
  KungfuRails	
  
                                  (stones.gao@gmail.com)	
  
What	
  can	
  you	
  do	
  with	
  Ac#veDirect	
  (examples)	
  	
  


App.models.Category.delete(	
  2	
  )	
  
App.models.Category.delete_all(	
  “	
  name	
  LIKE	
  	
  ‘%java%’	
  	
  “	
  	
  )	
  




                                                 Stone	
  Gao,	
  KungfuRails	
  
                                                (stones.gao@gmail.com)	
  
Wait,	
  Where	
  is	
  My	
  Controllers	
  ?!!	
  

     For	
  Ext	
  Js	
  Applica#ons,	
  you	
  don’t	
  necessarily	
  have	
  tradi#onal	
  Controllers	
  	
  


     You	
  front	
  end	
  control	
  logics	
  is	
  the	
  Controllers	
  and	
  Ext	
  Widgets	
  is	
  the	
  Views	
  



You	
  can	
  call	
  your	
  Model	
  methods	
  directly	
  using	
  Ext.Direct	
  	
  and	
  Ac#veDirect	
  




                                                     Stone	
  Gao,	
  KungfuRails	
  
                                                    (stones.gao@gmail.com)	
  
Let’s	
  Collaborate	
  to	
  Improve	
  it	
  	
  	
  




                 hTp://github.com/stonegao/acDve-­‐direct	
  

                  (It’s	
  my	
  first	
  library	
  	
  )	
  

                       Stone	
  Gao,	
  KungfuRails	
  
                      (stones.gao@gmail.com)	
  
Stone	
  Gao,	
  KungfuRails	
  
(stones.gao@gmail.com)	
  

Weitere ähnliche Inhalte

Ähnlich wie Talk Directly with ActiveRecord using Ext.Direct and Rack Middleware

Demoiselle Spatial Latinoware 2011
Demoiselle Spatial Latinoware 2011Demoiselle Spatial Latinoware 2011
Demoiselle Spatial Latinoware 2011Rafael Soto
 
Jackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSVJackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSVTatu Saloranta
 
Mongoskin - Guilin
Mongoskin - GuilinMongoskin - Guilin
Mongoskin - GuilinJackson Tian
 
Supercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamicSupercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamicIan Robertson
 
Opa presentation at GamesJs
Opa presentation at GamesJsOpa presentation at GamesJs
Opa presentation at GamesJsHenri Binsztok
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013Laurent_VB
 
Ti1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and ScopesTi1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and ScopesEelco Visser
 
Metaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And GrailsMetaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And GrailszenMonkey
 
The Future of JavaScript (Ajax Exp '07)
The Future of JavaScript (Ajax Exp '07)The Future of JavaScript (Ajax Exp '07)
The Future of JavaScript (Ajax Exp '07)jeresig
 
VJET bringing the best of Java and JavaScript together
VJET bringing the best of Java and JavaScript togetherVJET bringing the best of Java and JavaScript together
VJET bringing the best of Java and JavaScript togetherJustin Early
 
RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with JerseyScott Leberknight
 
Javaone 2010
Javaone 2010Javaone 2010
Javaone 2010Hien Luu
 
Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8 Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8 xshyamx
 
Type script, for dummies
Type script, for dummiesType script, for dummies
Type script, for dummiessantiagoaguiar
 

Ähnlich wie Talk Directly with ActiveRecord using Ext.Direct and Rack Middleware (20)

dojo.Patterns
dojo.Patternsdojo.Patterns
dojo.Patterns
 
Demoiselle Spatial Latinoware 2011
Demoiselle Spatial Latinoware 2011Demoiselle Spatial Latinoware 2011
Demoiselle Spatial Latinoware 2011
 
Jackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSVJackson beyond JSON: XML, CSV
Jackson beyond JSON: XML, CSV
 
Mongoskin - Guilin
Mongoskin - GuilinMongoskin - Guilin
Mongoskin - Guilin
 
Supercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamicSupercharging reflective libraries with InvokeDynamic
Supercharging reflective libraries with InvokeDynamic
 
Opa presentation at GamesJs
Opa presentation at GamesJsOpa presentation at GamesJs
Opa presentation at GamesJs
 
Developing web-apps like it's 2013
Developing web-apps like it's 2013Developing web-apps like it's 2013
Developing web-apps like it's 2013
 
Ti1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and ScopesTi1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and Scopes
 
Metaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And GrailsMetaprogramming Techniques In Groovy And Grails
Metaprogramming Techniques In Groovy And Grails
 
Json generation
Json generationJson generation
Json generation
 
The Future of JavaScript (Ajax Exp '07)
The Future of JavaScript (Ajax Exp '07)The Future of JavaScript (Ajax Exp '07)
The Future of JavaScript (Ajax Exp '07)
 
VJET bringing the best of Java and JavaScript together
VJET bringing the best of Java and JavaScript togetherVJET bringing the best of Java and JavaScript together
VJET bringing the best of Java and JavaScript together
 
RESTful Web Services with Jersey
RESTful Web Services with JerseyRESTful Web Services with Jersey
RESTful Web Services with Jersey
 
Javaone 2010
Javaone 2010Javaone 2010
Javaone 2010
 
Groovy's Builder
Groovy's BuilderGroovy's Builder
Groovy's Builder
 
Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8 Why is Java relevant? New features of Java8
Why is Java relevant? New features of Java8
 
Coding Ajax
Coding AjaxCoding Ajax
Coding Ajax
 
Type script, for dummies
Type script, for dummiesType script, for dummies
Type script, for dummies
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
Coding Ajax
Coding AjaxCoding Ajax
Coding Ajax
 

Kürzlich hochgeladen

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 

Kürzlich hochgeladen (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
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
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
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
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

Talk Directly with ActiveRecord using Ext.Direct and Rack Middleware

  • 1. Talk  Directly  with  Ac#veRecord     using  Ext.Direct  and  Rack  Middleware   Stone  Gao,  Ekohe   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 2. Outline   •  Intro  to  Ext  Js   •  The  Problem   •  The  SoluDon  :  Ext.Direct     •  Intro  to  Rack  Middleware   •  Ac#veDirect  (an  Experimental  ImplementaDon   of  Ext.Direct,  yet  )   •  What  can  you  do  with  Ac#veDirect  (Examples)   •  Q  &  A   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 3. Intro  to  Ext  Js   Ext  JS  is  a  cross-­‐browser  JavaScript  library  for  building  rich   internet  applicaDons.   •  igh  performance,  customizable  UI  widgets,  Ajax   H • ntuiDve,  easy  to  use  API   I                                                                                                                                                (hTp://www.extjs.com)     Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 4. The  Problem   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 5. Ajax  Calls   Foo.js   …….   Ext.Ajax.request({   Bar.js                      url:  ("/foo?format=json"),   ……   Baz.js                      method:  "POST",                      jsonData:    payLoad,   ……   Ext.Ajax.request({                      success:  this..success,                      url:  (”/bar?format=json"),                      failure:  this.failure,   Ext.Ajax.request({                      method:  ”GET",                      headers:  {                      jsonData:    payLoad,                      url:  (”/baz?format=json"),                          'accepts':  'applicaDon/json'                      success:  this..success,                      method:  "POST",                      },                      failure:  this.failure,                      jsonData:    payLoad,                      scope  :  this                      headers:  {                      success:  this..success,                  });                      failure:  this.failure,                          'accepts':  'applicaDon/json'                      },                      headers:  {   ……                      scope  :  this                          'accepts':  'applicaDon/json'                  });                      },                      scope  :  this   ……                  });   ……   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 6. Ajax  Calls   Foo.js   …….   Ext.Ajax.request({   Bar.js                      url:  ("/foo?format=json"),   ……   Baz.js                      method:  "POST",                      jsonData:    payLoad,   ……   Ext.Ajax.request({                      success:  this..success,                      url:  (”/bar?format=json"),                      failure:  this.failure,   Ext.Ajax.request({                      method:  ”GET",                      headers:  {                      jsonData:    payLoad,                      url:  (”/baz?format=json"),                          'accepts':  'applicaDon/json'                      success:  this..success,                      method:  "POST",                      },                      failure:  this.failure,                      jsonData:    payLoad,                      scope  :  this                      headers:  {                      success:  this..success,                  });                      failure:  this.failure,                          'accepts':  'applicaDon/json'                      },                      headers:  {   ……                      scope  :  this                          'accepts':  'applicaDon/json'                  });                      },                      scope  :  this   ……                  });   ……   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 7. The  SoluDon   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 8. The  SoluDon   Ext.Direct   Ext.Direct  is  a  pladorm  and  language  agnosDc  technology  to   remote  server-­‐side  methods  to  the  client-­‐side.  Furthermore,   Ext.Direct  allows  for  seamless  communicaDon  between  the   client-­‐side  of  an  Ext  applicaDon  and  any  server-­‐side  pladorm.   (hTp://www.extjs.com/products/extjs/direct.php)     You  can  write  the  following  code  in  javascript  :     App.models.Category.foo()   App.models.Category.bar()   App.models.Category.create(  {  name  :  ‘ruby’  }    )   App.models.Category.update(  1,  {  name  :  ‘ruby’  }    )   App.models.Category.delete(1)   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 9. Intro  to  Rack  Middleware     Middleware   App   HTTP  Request   HTTP   Client   log   auth   cache   (browser)   HTTP  Response   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 10. Intro  to  Rack  Middleware     >>    ps  aux  |  grep  ruby  |  wc  –l   3   Rack  Middleware  is  Pipeline  for  HTTP  Req  Processing!     Middleware   App   The  Unix  Philosophy  :     HTTP  Request   Rack  Middleware  is     Chainable   HTTP   and   Client   (browser)   HTTP  Response   log   auth   cache   Composable  like  Unix  Pipelines                     Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 11. Intro  to  Rack  Middleware     Conven#on  :  app.call(env)   lambda  {  |env|                                                                                #Rack  Environment  variables        [    200,                                                                                                            #Status  Code              {‘Content-­‐Type’  =>  ‘text/plain’},            #Headers                [‘Hello  World!’]                                                                    #Reponse  Body                                                        ]   }     Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 12. Ac#veDirect  (an  Experimental  ImplementaDon  of  Ext.Direct,  yet  )   Talk  Directly  with  Ac#veRecord  using  Ext.Direct  and  Rack  Middleware   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 13. Ac#veDirect  (an  Experimental  ImplementaDon  of  Ext.Direct,  yet  )   Talk  Directly  with  Ac#veRecord  using  Ext.Direct  and  Rack  Middleware   Method   Dispatching   AcDveDirect::Router   Ext.Direct     AcDveDirect::Api   Server-­‐side   App   methods  configs   Rack  Middleware   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 14. Ac#veDirect  (an  Experimental  ImplementaDon  of  Ext.Direct,  yet  )   How  Ac#veDirect::Api  works     App.REMOTING_API  =  {          "ac#ons":  {                  "Category":  [                          {                                  "name":  "all",                                  "len":  1   GET  /direct_api                          },                          {                                  "name":  "update_all",                                  "len":  2                          }                  ]          },          "namespace":  "App.models",          "url":  "/direct_router",          "type":  "remo#ng"   };   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 15. Ac#veDirect  (an  Experimental  ImplementaDon  of  Ext.Direct,  yet  )   How  Ac#veDirect::Router  works   App.models.Category.all()   POST  /direct_router          {"ac#on":"Category","method":"all","data":[],"type":"rpc","#d":3}   Ac#veDirect::Router   Category.send  :all   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 16. Ac#veDirect  -­‐  ConfiguraDon   •  Middleware  configuraDons  (environment.rb)            config.middleware.use  'Ac#veDirect::Router',  '/direct_router'            config.middleware.use  'Ac#veDirect::Api',  '/direct_api',  '/direct_router’   •  Method  configuraDons                <script  type="text/javascript"  src=”/javascripts/ext/adapter/ext/ext-­‐base.js"></script>              <script  type=“text/javascript”  src=”/javascripts/ext/ext-­‐all-­‐debug.js"></script>              <script  type=“text/javascript”  src=”/direct_api"></script>              Ext.Direct.addProvider(App.REMOTING_API);   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 17. Ac#veDirect  -­‐  ConfiguraDon   •  Model  configuraDons     class  Category  <  AcDveRecord::Base          acts_as_nested_set          has_many  :books          acts_as_direct    :root_nodes  =>  0,  :create_new_cat  =>  {:len  =>  1,  :formHandler  =>  true}          def  root_nodes                    ……          end            def  create_new_cat(params)     Custom  remotable                    ……   methods          end   end     Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 18. What  can  you  do  with  Ac#veDirect       CRUD  Default  Remotable  Methods   Custom  Remotable  Methods   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 19. What  can  you  do  with  Ac#veDirect  (examples)       App.models.Category.create(  {  name  :  ‘ruby’  }    )   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 20. What  can  you  do  with  Ac#veDirect  (examples)       App.models.Category.update(2,    {  name  :  ‘ruby  books’  }  )   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 21. What  can  you  do  with  Ac#veDirect  (examples)     App.models.Category.update_all({  name  :  ‘ruby  books’  },    “  name  LIKE  ‘%ruby%’  ”  )   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 22. What  can  you  do  with  Ac#veDirect  (examples)     App.models.Category.all()   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 23. What  can  you  do  with  Ac#veDirect  (examples)     App.models.Category.find(  2  )   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 24. What  can  you  do  with  Ac#veDirect  (examples)     App.models.Category.find_every(  {  condi#ons  :  “name  LIKE  ‘%java%’  “  }  )   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 25. What  can  you  do  with  Ac#veDirect  (examples)     App.models.Category.exists(  [“  name  LIKE  ?  “,    ‘%java%’  ]  )   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 26. What  can  you  do  with  Ac#veDirect  (examples)     Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 27. What  can  you  do  with  Ac#veDirect  (examples)     App.models.Category.count()   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 28. What  can  you  do  with  Ac#veDirect  (examples)     App.models.Category.delete(  2  )   App.models.Category.delete_all(  “  name  LIKE    ‘%java%’    “    )   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 29. Wait,  Where  is  My  Controllers  ?!!   For  Ext  Js  Applica#ons,  you  don’t  necessarily  have  tradi#onal  Controllers     You  front  end  control  logics  is  the  Controllers  and  Ext  Widgets  is  the  Views   You  can  call  your  Model  methods  directly  using  Ext.Direct    and  Ac#veDirect   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 30. Let’s  Collaborate  to  Improve  it       hTp://github.com/stonegao/acDve-­‐direct   (It’s  my  first  library    )   Stone  Gao,  KungfuRails   (stones.gao@gmail.com)  
  • 31. Stone  Gao,  KungfuRails   (stones.gao@gmail.com)