SlideShare a Scribd company logo
1 of 11
By: Ashan Fernando
   Introduction
   Technology Stack
   Project Structure
   High Level Architecture
   Frontend Architecture MVC
       View

       Collection

       Model

       Routes

   Backend Architecture MVC overview
       View/ Controller/ Model/ Route
A single-page application (SPA), also known
 as single-page interface (SPI), is a web
 application or web site that fits on a single
 web page with the goal of providing a more
 fluid user experience akin to a desktop
 application.

 ~ wikipedia
Ruby on Rails                           Java Script
   (Backend)                              (Frontend)
Jammit or Rails 3.1 + Asset           Backbone
Pipeline
                                      Backbone Relational
• Asset Packaging for Rails

RABL                                  Underscore
• (Ruby API Builder Language)         JQuery
DEVICE
                                      JQueryUI
• Authentication solution for Rails
                                      Modernizr
* Database
• MySQL                               Uniform
app/
        controllers/
          books_controller.rb
        models/
          book.rb
        views/
          books/
            index.rabl
          frontend/
            books/
              book.jst
        routes/
            routes.rb
       public/
         javascripts/
           application.js
           routes/
             booksAppRouter.js
           models/
             book.js
             library.js
           views/
             bookView.js​​

      Apart from this, the Database configuration/ Asset configurations are stored
       separately in respective folders
Ruby on Rails Platform
                                                                    Front End
                                                                    Web App
        Rails MVC
   RESTful Services & Content                                      Backbone MVC

                                                                    Collections
                                Routes         HTTP/JSON Request

       Controller                                                    Model
                                                                                  R
                                   HTTP/JSON Response                             o
                                                                                  u
                                                                                  t
                 Model                                                            e
                                   MySQL DB                          View         s

         View
var bookView = Backbone.View.extend({
        template: “books / book.jst",
        // reference to JST template
        events: {
           "click .icon": "open"
        },
        initialize() {
           this.render();
        },
        render: function() {
          var book = this.model.toJSON();
             $(this.el).html(this.JST({
                book: book
             }));
        },
        open: function() { // book open logic goes here
    }
   });
   When using this technology stack, the view content (HTML) are stored in JST
    files.
   At runtime JST files are converted into JavaScript functions (Underscore
    Template functions) using the Asset Pipeline (Jammit).

   Book.jst
       <h1><%= book.title %></h1>
        <div><%= book.content %></div>
        <div><%= book.footer %></div>

   Book JST after conversion to JavaScript
       var JST.book = function(book) {
           var out = "<h1>" + book.title + "</h1>";
           out += "<div>" + book.content + "</div>";
           out += "<div>" + book.footer + "</div>";
        }​
   Backbone collection is bind to a rest service
    using its url attribute

   var books = Backbone.Collection.extend({
       model: Book,
       url: '/books.json'
    });
   var book = Backbone.Model.extend({
    });
   A plug-in called backbone relational also can be used to add
    several models in relationship with eachother.
   var library = Backbone.RelationalModel.extend({
       relations: [{
         type: Backbone.HasMany,
         key: 'books',
         relatedModel: 'Book',
         reverseRelation: {
            key: 'storedAt',
            type: Backbone.HasOne
         }}]
    });
   Routes maps the request to the respective controller (request
    URL/operation mapping to controller)

   Controllers fetch a instance of a model and render the particular model
    using the respective view

   The instance of the model queried in the controller is readily available for
    the view and it renders the content using the respective model instance
    data. (HTML or JSON based on view template)

   Model reflects the instance of a database table in language structure

   All the assets (JavaScript/ Images/ CSS & etc.) are stored in Asset.yml and
    added to the respective resources using the asset pipeline (Jammit)

More Related Content

What's hot

Active Admin
Active AdminActive Admin
Active AdminGreg Bell
 
AngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro FrameworkAngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro FrameworkBackand Cohen
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Foreverstephskardal
 
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
 
Introduction à Ruby
Introduction à RubyIntroduction à Ruby
Introduction à RubyMicrosoft
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaJason Noble
 
PLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfAlfresco Software
 
The Chaos Tools Suite
The Chaos Tools SuiteThe Chaos Tools Suite
The Chaos Tools Suitemerlinofchaos
 
Ember,js: Hipster Hamster Framework
Ember,js: Hipster Hamster FrameworkEmber,js: Hipster Hamster Framework
Ember,js: Hipster Hamster FrameworkBilly Shih
 
Ch. 9 jsp standard tag library
Ch. 9 jsp standard tag libraryCh. 9 jsp standard tag library
Ch. 9 jsp standard tag libraryManolis Vavalis
 
multiple views and routing
multiple views and routingmultiple views and routing
multiple views and routingBrajesh Yadav
 
Leveraging the Chaos tool suite for module development
Leveraging the Chaos tool suite  for module developmentLeveraging the Chaos tool suite  for module development
Leveraging the Chaos tool suite for module developmentzroger
 
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Caldera Labs
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswanivvaswani
 

What's hot (20)

Active Admin
Active AdminActive Admin
Active Admin
 
AngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro FrameworkAngularJS with Slim PHP Micro Framework
AngularJS with Slim PHP Micro Framework
 
jQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends ForeverjQuery and Rails: Best Friends Forever
jQuery and Rails: Best Friends Forever
 
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
 
Introduction à Ruby
Introduction à RubyIntroduction à Ruby
Introduction à Ruby
 
Intro to Rails Give Camp Atlanta
Intro to Rails Give Camp AtlantaIntro to Rails Give Camp Atlanta
Intro to Rails Give Camp Atlanta
 
jQuery Intro
jQuery IntrojQuery Intro
jQuery Intro
 
PLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring Surf
 
Building rich Single Page Applications (SPAs) for desktop, mobile, and tablet...
Building rich Single Page Applications (SPAs) for desktop, mobile, and tablet...Building rich Single Page Applications (SPAs) for desktop, mobile, and tablet...
Building rich Single Page Applications (SPAs) for desktop, mobile, and tablet...
 
Catalog display
Catalog displayCatalog display
Catalog display
 
The Chaos Tools Suite
The Chaos Tools SuiteThe Chaos Tools Suite
The Chaos Tools Suite
 
Ember,js: Hipster Hamster Framework
Ember,js: Hipster Hamster FrameworkEmber,js: Hipster Hamster Framework
Ember,js: Hipster Hamster Framework
 
Ch. 9 jsp standard tag library
Ch. 9 jsp standard tag libraryCh. 9 jsp standard tag library
Ch. 9 jsp standard tag library
 
multiple views and routing
multiple views and routingmultiple views and routing
multiple views and routing
 
Dash of ajax
Dash of ajaxDash of ajax
Dash of ajax
 
Leveraging the Chaos tool suite for module development
Leveraging the Chaos tool suite  for module developmentLeveraging the Chaos tool suite  for module development
Leveraging the Chaos tool suite for module development
 
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
Single Page Web Apps As WordPress Admin Interfaces Using AngularJS & The Word...
 
Ch. 8 script free pages
Ch. 8 script free pagesCh. 8 script free pages
Ch. 8 script free pages
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 
AngularJS Best Practices
AngularJS Best PracticesAngularJS Best Practices
AngularJS Best Practices
 

Similar to SPA using Rails & Backbone

iPhone Web Development and Ruby On Rails
iPhone Web Development and Ruby On RailsiPhone Web Development and Ruby On Rails
iPhone Web Development and Ruby On RailsJose de Leon
 
Single Page Applications on JavaScript and ASP.NET MVC4
Single Page Applications on JavaScript and ASP.NET MVC4Single Page Applications on JavaScript and ASP.NET MVC4
Single Page Applications on JavaScript and ASP.NET MVC4Yuriy Shapovalov
 
Getting into ember.js
Getting into ember.jsGetting into ember.js
Getting into ember.jsreybango
 
Ruby On Rails Siddhesh
Ruby On Rails SiddheshRuby On Rails Siddhesh
Ruby On Rails SiddheshSiddhesh Bhobe
 
Javascript Frameworks for Well Architected, Immersive Web Apps
Javascript Frameworks for Well Architected, Immersive Web AppsJavascript Frameworks for Well Architected, Immersive Web Apps
Javascript Frameworks for Well Architected, Immersive Web Appsdnelson-cs
 
Client Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsClient Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsTom Z Zeng
 
A Semantic Wiki Based Light-Weight Web Application Model
A Semantic Wiki Based Light-Weight Web Application ModelA Semantic Wiki Based Light-Weight Web Application Model
A Semantic Wiki Based Light-Weight Web Application ModelJie Bao
 
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on RailsContent-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Railsbkraft
 
Jasig Rubyon Rails
Jasig Rubyon RailsJasig Rubyon Rails
Jasig Rubyon RailsPaul Pajo
 
Spring MVC introduction HVA
Spring MVC introduction HVASpring MVC introduction HVA
Spring MVC introduction HVAPeter Maas
 
Rails
RailsRails
RailsSHC
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course JavaEE Trainers
 
Introduction to backbone_js
Introduction to backbone_jsIntroduction to backbone_js
Introduction to backbone_jsMohammed Saqib
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAERon Reiter
 
quickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcquickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcjorgesimao71
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorialsunniboy
 

Similar to SPA using Rails & Backbone (20)

iPhone Web Development and Ruby On Rails
iPhone Web Development and Ruby On RailsiPhone Web Development and Ruby On Rails
iPhone Web Development and Ruby On Rails
 
Single Page Applications on JavaScript and ASP.NET MVC4
Single Page Applications on JavaScript and ASP.NET MVC4Single Page Applications on JavaScript and ASP.NET MVC4
Single Page Applications on JavaScript and ASP.NET MVC4
 
Getting into ember.js
Getting into ember.jsGetting into ember.js
Getting into ember.js
 
Ruby on rails RAD
Ruby on rails RADRuby on rails RAD
Ruby on rails RAD
 
Ruby On Rails Siddhesh
Ruby On Rails SiddheshRuby On Rails Siddhesh
Ruby On Rails Siddhesh
 
MVC
MVCMVC
MVC
 
Javascript Frameworks for Well Architected, Immersive Web Apps
Javascript Frameworks for Well Architected, Immersive Web AppsJavascript Frameworks for Well Architected, Immersive Web Apps
Javascript Frameworks for Well Architected, Immersive Web Apps
 
Client Side MVC with Backbone and Rails
Client Side MVC with Backbone and RailsClient Side MVC with Backbone and Rails
Client Side MVC with Backbone and Rails
 
A Semantic Wiki Based Light-Weight Web Application Model
A Semantic Wiki Based Light-Weight Web Application ModelA Semantic Wiki Based Light-Weight Web Application Model
A Semantic Wiki Based Light-Weight Web Application Model
 
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on RailsContent-Driven Web Applications with Magnolia CMS and Ruby on Rails
Content-Driven Web Applications with Magnolia CMS and Ruby on Rails
 
Spring mvc 2.0
Spring mvc 2.0Spring mvc 2.0
Spring mvc 2.0
 
Jasig Rubyon Rails
Jasig Rubyon RailsJasig Rubyon Rails
Jasig Rubyon Rails
 
Spring MVC introduction HVA
Spring MVC introduction HVASpring MVC introduction HVA
Spring MVC introduction HVA
 
BackboneJS + ReactJS
BackboneJS + ReactJSBackboneJS + ReactJS
BackboneJS + ReactJS
 
Rails
RailsRails
Rails
 
Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course Introduction to the Servlet / JSP course
Introduction to the Servlet / JSP course
 
Introduction to backbone_js
Introduction to backbone_jsIntroduction to backbone_js
Introduction to backbone_js
 
Writing HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAEWriting HTML5 Web Apps using Backbone.js and GAE
Writing HTML5 Web Apps using Backbone.js and GAE
 
quickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvcquickguide-einnovator-7-spring-mvc
quickguide-einnovator-7-spring-mvc
 
Ruby On Rails Tutorial
Ruby On Rails TutorialRuby On Rails Tutorial
Ruby On Rails Tutorial
 

Recently uploaded

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Orbitshub
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 

Recently uploaded (20)

Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 

SPA using Rails & Backbone

  • 2. Introduction  Technology Stack  Project Structure  High Level Architecture  Frontend Architecture MVC  View  Collection  Model  Routes  Backend Architecture MVC overview  View/ Controller/ Model/ Route
  • 3. A single-page application (SPA), also known as single-page interface (SPI), is a web application or web site that fits on a single web page with the goal of providing a more fluid user experience akin to a desktop application. ~ wikipedia
  • 4. Ruby on Rails Java Script (Backend) (Frontend) Jammit or Rails 3.1 + Asset Backbone Pipeline Backbone Relational • Asset Packaging for Rails RABL Underscore • (Ruby API Builder Language) JQuery DEVICE JQueryUI • Authentication solution for Rails Modernizr * Database • MySQL Uniform
  • 5. app/ controllers/ books_controller.rb models/ book.rb views/ books/ index.rabl frontend/ books/ book.jst routes/ routes.rb public/ javascripts/ application.js routes/ booksAppRouter.js models/ book.js library.js views/ bookView.js​​  Apart from this, the Database configuration/ Asset configurations are stored separately in respective folders
  • 6. Ruby on Rails Platform Front End Web App Rails MVC RESTful Services & Content Backbone MVC Collections Routes HTTP/JSON Request Controller Model R HTTP/JSON Response o u t Model e MySQL DB View s View
  • 7. var bookView = Backbone.View.extend({ template: “books / book.jst", // reference to JST template events: { "click .icon": "open" }, initialize() { this.render(); }, render: function() { var book = this.model.toJSON(); $(this.el).html(this.JST({ book: book })); }, open: function() { // book open logic goes here } });
  • 8. When using this technology stack, the view content (HTML) are stored in JST files.  At runtime JST files are converted into JavaScript functions (Underscore Template functions) using the Asset Pipeline (Jammit).  Book.jst  <h1><%= book.title %></h1> <div><%= book.content %></div> <div><%= book.footer %></div>  Book JST after conversion to JavaScript  var JST.book = function(book) { var out = "<h1>" + book.title + "</h1>"; out += "<div>" + book.content + "</div>"; out += "<div>" + book.footer + "</div>"; }​
  • 9. Backbone collection is bind to a rest service using its url attribute  var books = Backbone.Collection.extend({ model: Book, url: '/books.json' });
  • 10. var book = Backbone.Model.extend({ });  A plug-in called backbone relational also can be used to add several models in relationship with eachother.  var library = Backbone.RelationalModel.extend({ relations: [{ type: Backbone.HasMany, key: 'books', relatedModel: 'Book', reverseRelation: { key: 'storedAt', type: Backbone.HasOne }}] });
  • 11. Routes maps the request to the respective controller (request URL/operation mapping to controller)  Controllers fetch a instance of a model and render the particular model using the respective view  The instance of the model queried in the controller is readily available for the view and it renders the content using the respective model instance data. (HTML or JSON based on view template)  Model reflects the instance of a database table in language structure  All the assets (JavaScript/ Images/ CSS & etc.) are stored in Asset.yml and added to the respective resources using the asset pipeline (Jammit)

Editor's Notes

  1. A single-page application (SPA), also known as single-page interface (SPI), is a web application or web site that fits on a single web page with the goal of providing a more fluid user experience akin to a desktop application.The way traditional web applications work causes disruption in the user experience and workflow.SPAs address these issues by requiring no page reload by the browser during an application session. All user interaction and changes of the application state are handled in the context of a single Web document.