SlideShare a Scribd company logo
Enter the App Era
with Ruby on Rails

     @matteocollina
How is built an App?




               http://www.flickr.com/photos/dschulian/3173331821/
Code




       Icons by Fasticon
Code   Run




             Icons by Fasticon
Code   Run   Server




                      Icons by Fasticon
Code   Run   Server




                      Icons by Fasticon
Code   Run   Server




                      Icons by Fasticon
Code   I   need to
           serve
               Run   Server

     my data to
Web and Mobile Apps



                              Icons by Fasticon
We need an API
We need an API


Who has APIs?
Who has APIs?
Who has APIs?
Who has APIs?



And many many others..
We will develop an API
We need to be fast!




               http://www.flickr.com/photos/oneaustin/1261907803
We have just
twenty minutes




          http://www.flickr.com/photos/oneaustin/1261907803
What do we
want to build?   http://www.flickr.com/photos/oberazzi/318947873/
Another tool for nerds?




                          http://www.flickr.com/photos/eyesontheroad/2260731457/
Another Todo List?




                     http://www.flickr.com/photos/eyesontheroad/2260731457/
Enter MCDo.
http://github.com/mcollina/mcdo
Enter MCDo.

The first Todo List
  delivered as
   a REST API
The first Todo List
  delivered as
   a REST API
Signup API
http://github.com/mcollina/mcdo
Signup API
Feature: Signup API
  As a MCDO developer
  In order to develop apps
  I want to register new users

  Scenario: Succesful signup
    When I call "/users.json" in POST with:
      """
      {
        "user": {
          "email": "hello@abc.org",
          "password": "abcde",
          "password_confirmation": "abcde"
        }
      }
      """
    Then the JSON should be:
      """
      {
        "id": 1,
        "email": "hello@abc.org"
      }
      """
Signup API

Scenario: signup fails with a wrong password_confirmation
  When I call "/users.json" in POST with:
    """
    {
      "user": {
        "email": "hello@abc.org",
        "password": "abcde",
        "password_confirmation": "abcde1"
      }
    }
    """
  Then the JSON should be:
    """
    {
      "errors": { "password": ["doesn't match confirmation"] }
    }
    """
How?
How?

Ruby on Rails

Cucumber

RSpec

JSON-spec
How?

       Ruby on Rails


Let’s see some code!
       Cucumber

       RSpec

       JSON-spec
Login API
http://github.com/mcollina/mcdo
Login API
Feature: Login API
  As a MCDO developer
  In order to develop apps
  I want to login with an existing user

  Background:
    Given there is the following user:
      | email       | password | password_confirmation |
      | abcd@org.it | aa       | aa                    |

  Scenario: Succesful login
    When I call "/session.json" in POST with:
      """
      {
        "email": "abcd@org.it",
        "password": "aa"
      }
      """
    Then the JSON should be:
      """
      {
        "status": "authenticated"
      }
      """
Login API
Scenario: Failed login
  When I call "/session.json" in POST with:
    """
    {
      "email": "abcd@org.it",
      "password": "bb"
    }
    """
  Then the JSON should be:
    """
    {
      "status": "not authenticated"
    }
    """
Login API
Scenario: Validating an active session
    Given I call "/session.json" in POST with:
      """
      {
        "email": "abcd@org.it",
        "password": "aa"
      }
      """
    When I call "/session.json" in GET
    Then the JSON should be:
      """
      {
        "status": "authenticated"
      }
      """
Login API
  Scenario: Validating an active session
      Given I call "/session.json" in POST with:
        """
        {
          "email": "abcd@org.it",
          "password": "aa"
        }


Let’s see some code!
        """
      When I call "/session.json" in GET
      Then the JSON should be:
        """
        {
          "status": "authenticated"
        }
        """
Lists API
http://github.com/mcollina/mcdo
Lists API
Feature: Lists API
  As a MCDO developer
  In order to develop apps
  I want to manage a user's lists

  Background:
    Given I login succesfully with user "aaa@abc.org"

  Scenario: Default lists
    When I call "/lists.json" in GET
    Then the JSON should be:
      """
      {
        "lists": [{
           "id": 1,
           "name": "Personal",
           "link": "http://www.example.com/lists/1",
           "items_link": "http://www.example.com/lists/1/items"
        }]
      }
      """
Lists API

Scenario: Creating a list
  When I call "/lists.json" in POST with:
    """
    {
      "list": {
        "name": "foobar"
      }
    }
    """
  Then the JSON should be:
    """
    {
      "name": "foobar",
      "items_link": "http://www.example.com/lists/1/items"
    }
    """
Lists API
Scenario: Creating a list should add it to the index
  Given I call "/lists.json" in POST with:
    """
    {
      "list": {
         "name": "foobar"
      }
    }
    """
  When I call "/lists.json" in GET
  Then the JSON should be:
    """
    {
      "lists": [{
         "id": 2,
         "name": "foobar",
         "link": "http://www.example.com/lists/2",
         "items_link": "http://www.example.com/lists/2/items"
      }, {
         "id": 1,
         "name": "Personal",
         "link": "http://www.example.com/lists/1",
         "items_link": "http://www.example.com/lists/1/items"
      }]
    }
    """
Lists API
Scenario: Removing a list (and the index is empty)
  Given I call "/lists/1.json" in DELETE
  When I call "/lists.json"
  Then the JSON should be:
    """
    {
      "lists": []
    }
    """

Scenario: Updating a list's name
  When I call "/lists/1.json" in PUT with:
    """
    {
      "list": {
        "name": "foobar"
      }
    }
    """
  Then the JSON should be:
    """
    {
      "name": "foobar",
      "items_link": "http://www.example.com/lists/1/items"
    }
    """
Lists API
   Scenario: Removing a list (and the index is empty)
     Given I call "/lists/1.json" in DELETE
     When I call "/lists.json"
     Then the JSON should be:
       """
       {
         "lists": []
       }
       """


Let’s see some code!
   Scenario: Updating a list's name
     When I call "/lists/1.json" in PUT with:
       """
       {
         "list": {
           "name": "foobar"
         }
       }
       """
     Then the JSON should be:
       """
       {
         "name": "foobar",
         "items_link": "http://www.example.com/lists/1/items"
       }
       """
Items API
http://github.com/mcollina/mcdo
Items API
Feature: Manage a list's items
  As a developer
  In order to manipulate the list's item
  I want to access them through APIs

  Background:
    Given I login succesfully with user "aaa@abc.org"

  Scenario: Default items
    When I call "/lists/1/items.json" in GET
    Then the JSON should be:
    """
    {
      "items": [{
        "name": "Insert your items!",
        "position": 0
      }],
      "list_link": "http://www.example.com/lists/1"
    }
    """
Items API
Scenario: Moving an element to the top
  Given I call "/lists/1/items.json" in POST with:
  ...
  And I call "/lists/1/items.json" in POST with:
  ...
  When I call "/lists/1/items/2/move.json" in PUT with:
  """
  {
    "position": 0
  }
  """
  Then the JSON should be:
  """
  {
    "items": [{
      "name": "b",
      "position": 0
    }, {
      "name": "Insert your items!",
      "position": 1
    }, {
      "name": "c",
      "position": 2
    }],
    "list_link": "http://www.example.com/lists/1"
  }
  """
Items API
   Scenario: Moving an element to the top
     Given I call "/lists/1/items.json" in POST with:
     ...
     And I call "/lists/1/items.json" in POST with:
     ...
     When I call "/lists/1/items/2/move.json" in PUT with:
     """
     {
       "position": 0
     }


Let’s see some code!
     """
     Then the JSON should be:
     """
     {
       "items": [{
         "name": "b",
         "position": 0
       }, {
         "name": "Insert your items!",
         "position": 1
       }, {
         "name": "c",
         "position": 2
       }],
       "list_link": "http://www.example.com/lists/1"
     }
     """
Do we need
an admin panel?
Do we need
an admin panel?
Do we need
  an admin panel?
Put in your Gemfile:

  gem 'activeadmin'
  gem 'meta_search', '>= 1.1.0.pre'


Then run:

  $   bundle install
  $   rails g active_admin:install
  $   rails g active_admin:resource users
  $   rails g active_admin:resource lists
  $   rails g active_admin:resource items
  $   rake db:migrate
Do we need
  an admin panel?
Put in your Gemfile:




Let’s see some code!
  gem 'activeadmin'
  gem 'meta_search', '>= 1.1.0.pre'


Then run:

  $   bundle install
  $   rails g active_admin:install
  $   rails g active_admin:resource users
  $   rails g active_admin:resource lists
  $   rails g active_admin:resource items
  $   rake db:migrate
Build a JS App!
Do you like
Spaghetti
 Code?
JavaScript Apps are
often a mess

We mix logic with
presentation with
persistance.

Packaging is hard.
                      http://www.flickr.com/photos/mpirotta/4944504834
What we want



           http://www.flickr.com/photos/bob_u/208396193
Rethinking MVC

 MVC pattern was
 introduced with Smalltalk
 too many years ago.

 In “true” MVC the “View”
 updates itself when the
 model changes.

 We could not port it to the
 Rails world.

                               http://www.flickr.com/photos/wbaiv/2554954565
Build a JS App the Rails Way!


      Backbone.js: MVC in the browser

      Rails asset pipeline concatenate
    and minifies our JS automatically

     We can even write our app in
    CoffeeScript: it works out of the box.
Build a JS App the Rails Way!


      Backbone.js: MVC in the browser

   to Rails asset pipeline concatenate
       the code.. again?
    and minifies our JS automatically

     We can even write our app in
    CoffeeScript: it works out of the box.
http://www.flickr.com/photos/oneaustin/1261907803
We are late,
     the #rubyday
crew are kicking me out!



                 http://www.flickr.com/photos/oneaustin/1261907803
TL;DR




        http://www.flickr.com/photos/evilaugust/3307382858
TL;DR

  Mobile Apps need an API

  Ruby on Rails is good for writing APIs

  You can build nice admin interfaces
with ActiveAdmin

  You can craft Javascript Apps easily
using the asset pipeline.
Any Questions?
Matteo Collina

Software Engineer

@matteocollina

matteocollina.com
www.mavigex.com
   www.wemobi.it
Thank You!
Ad

More Related Content

What's hot (20)

Finding Restfulness - Madrid.rb April 2014
Finding Restfulness - Madrid.rb April 2014Finding Restfulness - Madrid.rb April 2014
Finding Restfulness - Madrid.rb April 2014
samlown
 
Api
ApiApi
Api
randyhoyt
 
Mashups & APIs
Mashups & APIsMashups & APIs
Mashups & APIs
Pamela Fox
 
Consume RESTful APIs with $resource and Restangular
Consume RESTful APIs with $resource and RestangularConsume RESTful APIs with $resource and Restangular
Consume RESTful APIs with $resource and Restangular
John Schmidt
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET Core
Stormpath
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
tomdale
 
Integrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software CloudIntegrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software Cloud
Atlassian
 
Build REST API clients for AngularJS
Build REST API clients for AngularJSBuild REST API clients for AngularJS
Build REST API clients for AngularJS
Almog Baku
 
Introduction à Ruby
Introduction à RubyIntroduction à Ruby
Introduction à Ruby
Microsoft
 
Crafting Quality PHP Applications (ConFoo YVR 2017)
Crafting Quality PHP Applications (ConFoo YVR 2017)Crafting Quality PHP Applications (ConFoo YVR 2017)
Crafting Quality PHP Applications (ConFoo YVR 2017)
James Titcumb
 
Designing beautiful REST APIs
Designing beautiful REST APIsDesigning beautiful REST APIs
Designing beautiful REST APIs
Tomek Cejner
 
Crafting Quality PHP Applications (Bucharest Tech Week 2017)
Crafting Quality PHP Applications (Bucharest Tech Week 2017)Crafting Quality PHP Applications (Bucharest Tech Week 2017)
Crafting Quality PHP Applications (Bucharest Tech Week 2017)
James Titcumb
 
BDD - Writing better scenario
BDD - Writing better scenarioBDD - Writing better scenario
BDD - Writing better scenario
Arnauld Loyer
 
How we improved performance at Mixbook
How we improved performance at MixbookHow we improved performance at Mixbook
How we improved performance at Mixbook
Anton Astashov
 
A Tour of Wyriki
A Tour of WyrikiA Tour of Wyriki
A Tour of Wyriki
Mark Menard
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
Sean Cribbs
 
Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)
Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)
Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)
James Titcumb
 
Crafting Quality PHP Applications (PHPkonf 2018)
Crafting Quality PHP Applications (PHPkonf 2018)Crafting Quality PHP Applications (PHPkonf 2018)
Crafting Quality PHP Applications (PHPkonf 2018)
James Titcumb
 
Crafting Quality PHP Applications (PHP Benelux 2018)
Crafting Quality PHP Applications (PHP Benelux 2018)Crafting Quality PHP Applications (PHP Benelux 2018)
Crafting Quality PHP Applications (PHP Benelux 2018)
James Titcumb
 
Integrating WordPress With Web APIs
Integrating WordPress With Web APIsIntegrating WordPress With Web APIs
Integrating WordPress With Web APIs
randyhoyt
 
Finding Restfulness - Madrid.rb April 2014
Finding Restfulness - Madrid.rb April 2014Finding Restfulness - Madrid.rb April 2014
Finding Restfulness - Madrid.rb April 2014
samlown
 
Mashups & APIs
Mashups & APIsMashups & APIs
Mashups & APIs
Pamela Fox
 
Consume RESTful APIs with $resource and Restangular
Consume RESTful APIs with $resource and RestangularConsume RESTful APIs with $resource and Restangular
Consume RESTful APIs with $resource and Restangular
John Schmidt
 
Building Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET CoreBuilding Beautiful REST APIs in ASP.NET Core
Building Beautiful REST APIs in ASP.NET Core
Stormpath
 
SproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFestSproutCore is Awesome - HTML5 Summer DevFest
SproutCore is Awesome - HTML5 Summer DevFest
tomdale
 
Integrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software CloudIntegrate CI/CD Pipelines with Jira Software Cloud
Integrate CI/CD Pipelines with Jira Software Cloud
Atlassian
 
Build REST API clients for AngularJS
Build REST API clients for AngularJSBuild REST API clients for AngularJS
Build REST API clients for AngularJS
Almog Baku
 
Introduction à Ruby
Introduction à RubyIntroduction à Ruby
Introduction à Ruby
Microsoft
 
Crafting Quality PHP Applications (ConFoo YVR 2017)
Crafting Quality PHP Applications (ConFoo YVR 2017)Crafting Quality PHP Applications (ConFoo YVR 2017)
Crafting Quality PHP Applications (ConFoo YVR 2017)
James Titcumb
 
Designing beautiful REST APIs
Designing beautiful REST APIsDesigning beautiful REST APIs
Designing beautiful REST APIs
Tomek Cejner
 
Crafting Quality PHP Applications (Bucharest Tech Week 2017)
Crafting Quality PHP Applications (Bucharest Tech Week 2017)Crafting Quality PHP Applications (Bucharest Tech Week 2017)
Crafting Quality PHP Applications (Bucharest Tech Week 2017)
James Titcumb
 
BDD - Writing better scenario
BDD - Writing better scenarioBDD - Writing better scenario
BDD - Writing better scenario
Arnauld Loyer
 
How we improved performance at Mixbook
How we improved performance at MixbookHow we improved performance at Mixbook
How we improved performance at Mixbook
Anton Astashov
 
A Tour of Wyriki
A Tour of WyrikiA Tour of Wyriki
A Tour of Wyriki
Mark Menard
 
Story Driven Development With Cucumber
Story Driven Development With CucumberStory Driven Development With Cucumber
Story Driven Development With Cucumber
Sean Cribbs
 
Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)
Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)
Kicking off with Zend Expressive and Doctrine ORM (ConFoo YVR 2017)
James Titcumb
 
Crafting Quality PHP Applications (PHPkonf 2018)
Crafting Quality PHP Applications (PHPkonf 2018)Crafting Quality PHP Applications (PHPkonf 2018)
Crafting Quality PHP Applications (PHPkonf 2018)
James Titcumb
 
Crafting Quality PHP Applications (PHP Benelux 2018)
Crafting Quality PHP Applications (PHP Benelux 2018)Crafting Quality PHP Applications (PHP Benelux 2018)
Crafting Quality PHP Applications (PHP Benelux 2018)
James Titcumb
 
Integrating WordPress With Web APIs
Integrating WordPress With Web APIsIntegrating WordPress With Web APIs
Integrating WordPress With Web APIs
randyhoyt
 

Viewers also liked (18)

E così vuoi sviluppare un'app
E così vuoi sviluppare un'appE così vuoi sviluppare un'app
E così vuoi sviluppare un'app
Matteo Collina
 
Crea il TUO database con LevelDB e Node.js
Crea il TUO database con LevelDB e Node.jsCrea il TUO database con LevelDB e Node.js
Crea il TUO database con LevelDB e Node.js
Matteo Collina
 
The usability of open data
The usability of open dataThe usability of open data
The usability of open data
Matteo Collina
 
No. la sottile arte di trovare il tempo dove non esite.
No. la sottile arte di trovare il tempo dove non esite.No. la sottile arte di trovare il tempo dove non esite.
No. la sottile arte di trovare il tempo dove non esite.
Matteo Collina
 
Making things that works with us codemotion
Making things that works with us   codemotionMaking things that works with us   codemotion
Making things that works with us codemotion
Matteo Collina
 
E così vuoi sviluppare un'app (ci servono le APi!)
E così vuoi sviluppare un'app (ci servono le APi!)E così vuoi sviluppare un'app (ci servono le APi!)
E così vuoi sviluppare un'app (ci servono le APi!)
Matteo Collina
 
Making things that works with us
Making things that works with usMaking things that works with us
Making things that works with us
Matteo Collina
 
CI-18n
CI-18nCI-18n
CI-18n
Matteo Collina
 
Making things that works with us - First Italian Internet of Things Day
Making things that works with us - First Italian Internet of Things DayMaking things that works with us - First Italian Internet of Things Day
Making things that works with us - First Italian Internet of Things Day
Matteo Collina
 
The internet of things - Rails Girls Galway
The internet of things - Rails Girls GalwayThe internet of things - Rails Girls Galway
The internet of things - Rails Girls Galway
Matteo Collina
 
Building a multi protocol broker for the internet of things using nodejs
Building a multi protocol broker for the internet of things using nodejsBuilding a multi protocol broker for the internet of things using nodejs
Building a multi protocol broker for the internet of things using nodejs
Matteo Collina
 
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Matteo Collina
 
L'universo dietro alle App
L'universo dietro alle AppL'universo dietro alle App
L'universo dietro alle App
Matteo Collina
 
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
Matteo Collina
 
Operational transformation
Operational transformationOperational transformation
Operational transformation
Matteo Collina
 
Exposing M2M to the REST of us
Exposing M2M to the REST of usExposing M2M to the REST of us
Exposing M2M to the REST of us
Matteo Collina
 
Making things that work with us - Distill
Making things that work with us - DistillMaking things that work with us - Distill
Making things that work with us - Distill
Matteo Collina
 
Making your washing machine talk with a power plant
Making your washing machine talk with a power plantMaking your washing machine talk with a power plant
Making your washing machine talk with a power plant
Matteo Collina
 
E così vuoi sviluppare un'app
E così vuoi sviluppare un'appE così vuoi sviluppare un'app
E così vuoi sviluppare un'app
Matteo Collina
 
Crea il TUO database con LevelDB e Node.js
Crea il TUO database con LevelDB e Node.jsCrea il TUO database con LevelDB e Node.js
Crea il TUO database con LevelDB e Node.js
Matteo Collina
 
The usability of open data
The usability of open dataThe usability of open data
The usability of open data
Matteo Collina
 
No. la sottile arte di trovare il tempo dove non esite.
No. la sottile arte di trovare il tempo dove non esite.No. la sottile arte di trovare il tempo dove non esite.
No. la sottile arte di trovare il tempo dove non esite.
Matteo Collina
 
Making things that works with us codemotion
Making things that works with us   codemotionMaking things that works with us   codemotion
Making things that works with us codemotion
Matteo Collina
 
E così vuoi sviluppare un'app (ci servono le APi!)
E così vuoi sviluppare un'app (ci servono le APi!)E così vuoi sviluppare un'app (ci servono le APi!)
E così vuoi sviluppare un'app (ci servono le APi!)
Matteo Collina
 
Making things that works with us
Making things that works with usMaking things that works with us
Making things that works with us
Matteo Collina
 
Making things that works with us - First Italian Internet of Things Day
Making things that works with us - First Italian Internet of Things DayMaking things that works with us - First Italian Internet of Things Day
Making things that works with us - First Italian Internet of Things Day
Matteo Collina
 
The internet of things - Rails Girls Galway
The internet of things - Rails Girls GalwayThe internet of things - Rails Girls Galway
The internet of things - Rails Girls Galway
Matteo Collina
 
Building a multi protocol broker for the internet of things using nodejs
Building a multi protocol broker for the internet of things using nodejsBuilding a multi protocol broker for the internet of things using nodejs
Building a multi protocol broker for the internet of things using nodejs
Matteo Collina
 
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...Designing and developing mobile web applications with Mockup, Sencha Touch an...
Designing and developing mobile web applications with Mockup, Sencha Touch an...
Matteo Collina
 
L'universo dietro alle App
L'universo dietro alle AppL'universo dietro alle App
L'universo dietro alle App
Matteo Collina
 
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
No. la sottile arte di trovare il tempo dove non esite - codemotion 2015
Matteo Collina
 
Operational transformation
Operational transformationOperational transformation
Operational transformation
Matteo Collina
 
Exposing M2M to the REST of us
Exposing M2M to the REST of usExposing M2M to the REST of us
Exposing M2M to the REST of us
Matteo Collina
 
Making things that work with us - Distill
Making things that work with us - DistillMaking things that work with us - Distill
Making things that work with us - Distill
Matteo Collina
 
Making your washing machine talk with a power plant
Making your washing machine talk with a power plantMaking your washing machine talk with a power plant
Making your washing machine talk with a power plant
Matteo Collina
 
Ad

Similar to Enter the app era with ruby on rails (rubyday) (20)

API
APIAPI
API
Masters Academy
 
Women Who Code - RSpec JSON API Workshop
Women Who Code - RSpec JSON API WorkshopWomen Who Code - RSpec JSON API Workshop
Women Who Code - RSpec JSON API Workshop
Eddie Lau
 
A Deep Dive into RESTful API Design Part 2
A Deep Dive into RESTful API Design Part 2A Deep Dive into RESTful API Design Part 2
A Deep Dive into RESTful API Design Part 2
VivekKrishna34
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.
Mario Cardinal
 
Android App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAndroid App Development 06 : Network & Web Services
Android App Development 06 : Network & Web Services
Anuchit Chalothorn
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
darrelmiller71
 
AMS, API, RAILS and a developer, a Love Story
AMS, API, RAILS and a developer, a Love StoryAMS, API, RAILS and a developer, a Love Story
AMS, API, RAILS and a developer, a Love Story
João Moura
 
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IWeb Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day I
Anuchit Chalothorn
 
APIs REST Usables con Hypermedia por Javier Ramirez, para codemotion
APIs REST Usables con Hypermedia por Javier Ramirez, para codemotionAPIs REST Usables con Hypermedia por Javier Ramirez, para codemotion
APIs REST Usables con Hypermedia por Javier Ramirez, para codemotion
javier ramirez
 
Web Services with Objective-C
Web Services with Objective-CWeb Services with Objective-C
Web Services with Objective-C
Juio Barros
 
Build an API the right way
Build an API the right wayBuild an API the right way
Build an API the right way
Software Guru
 
REST Methodologies
REST MethodologiesREST Methodologies
REST Methodologies
jrodbx
 
Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017
JoEllen Carter
 
7 network programmability concepts api
7 network programmability concepts api7 network programmability concepts api
7 network programmability concepts api
SagarR24
 
Api fundamentals
Api fundamentalsApi fundamentals
Api fundamentals
AgileDenver
 
Api presentation
Api presentationApi presentation
Api presentation
Tiago Cardoso
 
Android and REST
Android and RESTAndroid and REST
Android and REST
Roman Woźniak
 
Building Awesome APIs in Grails
Building Awesome APIs in GrailsBuilding Awesome APIs in Grails
Building Awesome APIs in Grails
clatimer
 
Создание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружениеСоздание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружение
SQALab
 
API Design & Security in django
API Design & Security in djangoAPI Design & Security in django
API Design & Security in django
Tareque Hossain
 
Women Who Code - RSpec JSON API Workshop
Women Who Code - RSpec JSON API WorkshopWomen Who Code - RSpec JSON API Workshop
Women Who Code - RSpec JSON API Workshop
Eddie Lau
 
A Deep Dive into RESTful API Design Part 2
A Deep Dive into RESTful API Design Part 2A Deep Dive into RESTful API Design Part 2
A Deep Dive into RESTful API Design Part 2
VivekKrishna34
 
Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.Best Practices for Architecting a Pragmatic Web API.
Best Practices for Architecting a Pragmatic Web API.
Mario Cardinal
 
Android App Development 06 : Network & Web Services
Android App Development 06 : Network & Web ServicesAndroid App Development 06 : Network & Web Services
Android App Development 06 : Network & Web Services
Anuchit Chalothorn
 
Crafting Evolvable Api Responses
Crafting Evolvable Api ResponsesCrafting Evolvable Api Responses
Crafting Evolvable Api Responses
darrelmiller71
 
AMS, API, RAILS and a developer, a Love Story
AMS, API, RAILS and a developer, a Love StoryAMS, API, RAILS and a developer, a Love Story
AMS, API, RAILS and a developer, a Love Story
João Moura
 
Web Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day IWeb Service and Mobile Integrated Day I
Web Service and Mobile Integrated Day I
Anuchit Chalothorn
 
APIs REST Usables con Hypermedia por Javier Ramirez, para codemotion
APIs REST Usables con Hypermedia por Javier Ramirez, para codemotionAPIs REST Usables con Hypermedia por Javier Ramirez, para codemotion
APIs REST Usables con Hypermedia por Javier Ramirez, para codemotion
javier ramirez
 
Web Services with Objective-C
Web Services with Objective-CWeb Services with Objective-C
Web Services with Objective-C
Juio Barros
 
Build an API the right way
Build an API the right wayBuild an API the right way
Build an API the right way
Software Guru
 
REST Methodologies
REST MethodologiesREST Methodologies
REST Methodologies
jrodbx
 
Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017Api FUNdamentals #MHA2017
Api FUNdamentals #MHA2017
JoEllen Carter
 
7 network programmability concepts api
7 network programmability concepts api7 network programmability concepts api
7 network programmability concepts api
SagarR24
 
Api fundamentals
Api fundamentalsApi fundamentals
Api fundamentals
AgileDenver
 
Building Awesome APIs in Grails
Building Awesome APIs in GrailsBuilding Awesome APIs in Grails
Building Awesome APIs in Grails
clatimer
 
Создание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружениеСоздание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружение
SQALab
 
API Design & Security in django
API Design & Security in djangoAPI Design & Security in django
API Design & Security in django
Tareque Hossain
 
Ad

Recently uploaded (20)

DNF 2.0 Implementations Challenges in Nepal
DNF 2.0 Implementations Challenges in NepalDNF 2.0 Implementations Challenges in Nepal
DNF 2.0 Implementations Challenges in Nepal
ICT Frame Magazine Pvt. Ltd.
 
Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025
Damco Salesforce Services
 
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
UXPA Boston
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Vasileios Komianos
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Breaking it Down: Microservices Architecture for PHP Developers
Breaking it Down: Microservices Architecture for PHP DevelopersBreaking it Down: Microservices Architecture for PHP Developers
Breaking it Down: Microservices Architecture for PHP Developers
pmeth1
 
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
Toru Tamaki
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc
 
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
ICT Frame Magazine Pvt. Ltd.
 
AI and Meaningful Work by Pablo Fernández Vallejo
AI and Meaningful Work by Pablo Fernández VallejoAI and Meaningful Work by Pablo Fernández Vallejo
AI and Meaningful Work by Pablo Fernández Vallejo
UXPA Boston
 
Computer Systems Quiz Presentation in Purple Bold Style (4).pdf
Computer Systems Quiz Presentation in Purple Bold Style (4).pdfComputer Systems Quiz Presentation in Purple Bold Style (4).pdf
Computer Systems Quiz Presentation in Purple Bold Style (4).pdf
fizarcse
 
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More MachinesRefactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Leon Anavi
 
SQL Database Design For Developers at PhpTek 2025.pptx
SQL Database Design For Developers at PhpTek 2025.pptxSQL Database Design For Developers at PhpTek 2025.pptx
SQL Database Design For Developers at PhpTek 2025.pptx
Scott Keck-Warren
 
Is Your QA Team Still Working in Silos? Here's What to Do.
Is Your QA Team Still Working in Silos? Here's What to Do.Is Your QA Team Still Working in Silos? Here's What to Do.
Is Your QA Team Still Working in Silos? Here's What to Do.
marketing943205
 
RFID in Supply chain management and logistics.pdf
RFID in Supply chain management and logistics.pdfRFID in Supply chain management and logistics.pdf
RFID in Supply chain management and logistics.pdf
EnCStore Private Limited
 
Whose choice? Making decisions with and about Artificial Intelligence, Keele ...
Whose choice? Making decisions with and about Artificial Intelligence, Keele ...Whose choice? Making decisions with and about Artificial Intelligence, Keele ...
Whose choice? Making decisions with and about Artificial Intelligence, Keele ...
Alan Dix
 
Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025Top 5 Qualities to Look for in Salesforce Partners in 2025
Top 5 Qualities to Look for in Salesforce Partners in 2025
Damco Salesforce Services
 
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
Developing Product-Behavior Fit: UX Research in Product Development by Krysta...
UXPA Boston
 
May Patch Tuesday
May Patch TuesdayMay Patch Tuesday
May Patch Tuesday
Ivanti
 
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Digital Technologies for Culture, Arts and Heritage: Insights from Interdisci...
Vasileios Komianos
 
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Integrating FME with Python: Tips, Demos, and Best Practices for Powerful Aut...
Safe Software
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Breaking it Down: Microservices Architecture for PHP Developers
Breaking it Down: Microservices Architecture for PHP DevelopersBreaking it Down: Microservices Architecture for PHP Developers
Breaking it Down: Microservices Architecture for PHP Developers
pmeth1
 
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
論文紹介:"InfLoRA: Interference-Free Low-Rank Adaptation for Continual Learning" ...
Toru Tamaki
 
Mastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B LandscapeMastering Testing in the Modern F&B Landscape
Mastering Testing in the Modern F&B Landscape
marketing943205
 
Building the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdfBuilding the Customer Identity Community, Together.pdf
Building the Customer Identity Community, Together.pdf
Cheryl Hung
 
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc Webinar: Cross-Border Data Transfers in 2025
TrustArc
 
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
MULTI-STAKEHOLDER CONSULTATION PROGRAM On Implementation of DNF 2.0 and Way F...
ICT Frame Magazine Pvt. Ltd.
 
AI and Meaningful Work by Pablo Fernández Vallejo
AI and Meaningful Work by Pablo Fernández VallejoAI and Meaningful Work by Pablo Fernández Vallejo
AI and Meaningful Work by Pablo Fernández Vallejo
UXPA Boston
 
Computer Systems Quiz Presentation in Purple Bold Style (4).pdf
Computer Systems Quiz Presentation in Purple Bold Style (4).pdfComputer Systems Quiz Presentation in Purple Bold Style (4).pdf
Computer Systems Quiz Presentation in Purple Bold Style (4).pdf
fizarcse
 
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More MachinesRefactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Refactoring meta-rauc-community: Cleaner Code, Better Maintenance, More Machines
Leon Anavi
 
SQL Database Design For Developers at PhpTek 2025.pptx
SQL Database Design For Developers at PhpTek 2025.pptxSQL Database Design For Developers at PhpTek 2025.pptx
SQL Database Design For Developers at PhpTek 2025.pptx
Scott Keck-Warren
 
Is Your QA Team Still Working in Silos? Here's What to Do.
Is Your QA Team Still Working in Silos? Here's What to Do.Is Your QA Team Still Working in Silos? Here's What to Do.
Is Your QA Team Still Working in Silos? Here's What to Do.
marketing943205
 
RFID in Supply chain management and logistics.pdf
RFID in Supply chain management and logistics.pdfRFID in Supply chain management and logistics.pdf
RFID in Supply chain management and logistics.pdf
EnCStore Private Limited
 
Whose choice? Making decisions with and about Artificial Intelligence, Keele ...
Whose choice? Making decisions with and about Artificial Intelligence, Keele ...Whose choice? Making decisions with and about Artificial Intelligence, Keele ...
Whose choice? Making decisions with and about Artificial Intelligence, Keele ...
Alan Dix
 

Enter the app era with ruby on rails (rubyday)

  • 1. Enter the App Era with Ruby on Rails @matteocollina
  • 2. How is built an App? http://www.flickr.com/photos/dschulian/3173331821/
  • 3. Code Icons by Fasticon
  • 4. Code Run Icons by Fasticon
  • 5. Code Run Server Icons by Fasticon
  • 6. Code Run Server Icons by Fasticon
  • 7. Code Run Server Icons by Fasticon
  • 8. Code I need to serve Run Server my data to Web and Mobile Apps Icons by Fasticon
  • 10. We need an API Who has APIs?
  • 13. Who has APIs? And many many others..
  • 14. We will develop an API
  • 15. We need to be fast! http://www.flickr.com/photos/oneaustin/1261907803
  • 16. We have just twenty minutes http://www.flickr.com/photos/oneaustin/1261907803
  • 17. What do we want to build? http://www.flickr.com/photos/oberazzi/318947873/
  • 18. Another tool for nerds? http://www.flickr.com/photos/eyesontheroad/2260731457/
  • 19. Another Todo List? http://www.flickr.com/photos/eyesontheroad/2260731457/
  • 21. Enter MCDo. The first Todo List delivered as a REST API
  • 22. The first Todo List delivered as a REST API
  • 24. Signup API Feature: Signup API As a MCDO developer In order to develop apps I want to register new users Scenario: Succesful signup When I call "/users.json" in POST with: """ { "user": { "email": "[email protected]", "password": "abcde", "password_confirmation": "abcde" } } """ Then the JSON should be: """ { "id": 1, "email": "[email protected]" } """
  • 25. Signup API Scenario: signup fails with a wrong password_confirmation When I call "/users.json" in POST with: """ { "user": { "email": "[email protected]", "password": "abcde", "password_confirmation": "abcde1" } } """ Then the JSON should be: """ { "errors": { "password": ["doesn't match confirmation"] } } """
  • 26. How?
  • 28. How? Ruby on Rails Let’s see some code! Cucumber RSpec JSON-spec
  • 30. Login API Feature: Login API As a MCDO developer In order to develop apps I want to login with an existing user Background: Given there is the following user: | email | password | password_confirmation | | [email protected] | aa | aa | Scenario: Succesful login When I call "/session.json" in POST with: """ { "email": "[email protected]", "password": "aa" } """ Then the JSON should be: """ { "status": "authenticated" } """
  • 31. Login API Scenario: Failed login When I call "/session.json" in POST with: """ { "email": "[email protected]", "password": "bb" } """ Then the JSON should be: """ { "status": "not authenticated" } """
  • 32. Login API Scenario: Validating an active session Given I call "/session.json" in POST with: """ { "email": "[email protected]", "password": "aa" } """ When I call "/session.json" in GET Then the JSON should be: """ { "status": "authenticated" } """
  • 33. Login API Scenario: Validating an active session Given I call "/session.json" in POST with: """ { "email": "[email protected]", "password": "aa" } Let’s see some code! """ When I call "/session.json" in GET Then the JSON should be: """ { "status": "authenticated" } """
  • 35. Lists API Feature: Lists API As a MCDO developer In order to develop apps I want to manage a user's lists Background: Given I login succesfully with user "[email protected]" Scenario: Default lists When I call "/lists.json" in GET Then the JSON should be: """ { "lists": [{ "id": 1, "name": "Personal", "link": "http://www.example.com/lists/1", "items_link": "http://www.example.com/lists/1/items" }] } """
  • 36. Lists API Scenario: Creating a list When I call "/lists.json" in POST with: """ { "list": { "name": "foobar" } } """ Then the JSON should be: """ { "name": "foobar", "items_link": "http://www.example.com/lists/1/items" } """
  • 37. Lists API Scenario: Creating a list should add it to the index Given I call "/lists.json" in POST with: """ { "list": { "name": "foobar" } } """ When I call "/lists.json" in GET Then the JSON should be: """ { "lists": [{ "id": 2, "name": "foobar", "link": "http://www.example.com/lists/2", "items_link": "http://www.example.com/lists/2/items" }, { "id": 1, "name": "Personal", "link": "http://www.example.com/lists/1", "items_link": "http://www.example.com/lists/1/items" }] } """
  • 38. Lists API Scenario: Removing a list (and the index is empty) Given I call "/lists/1.json" in DELETE When I call "/lists.json" Then the JSON should be: """ { "lists": [] } """ Scenario: Updating a list's name When I call "/lists/1.json" in PUT with: """ { "list": { "name": "foobar" } } """ Then the JSON should be: """ { "name": "foobar", "items_link": "http://www.example.com/lists/1/items" } """
  • 39. Lists API Scenario: Removing a list (and the index is empty) Given I call "/lists/1.json" in DELETE When I call "/lists.json" Then the JSON should be: """ { "lists": [] } """ Let’s see some code! Scenario: Updating a list's name When I call "/lists/1.json" in PUT with: """ { "list": { "name": "foobar" } } """ Then the JSON should be: """ { "name": "foobar", "items_link": "http://www.example.com/lists/1/items" } """
  • 41. Items API Feature: Manage a list's items As a developer In order to manipulate the list's item I want to access them through APIs Background: Given I login succesfully with user "[email protected]" Scenario: Default items When I call "/lists/1/items.json" in GET Then the JSON should be: """ { "items": [{ "name": "Insert your items!", "position": 0 }], "list_link": "http://www.example.com/lists/1" } """
  • 42. Items API Scenario: Moving an element to the top Given I call "/lists/1/items.json" in POST with: ... And I call "/lists/1/items.json" in POST with: ... When I call "/lists/1/items/2/move.json" in PUT with: """ { "position": 0 } """ Then the JSON should be: """ { "items": [{ "name": "b", "position": 0 }, { "name": "Insert your items!", "position": 1 }, { "name": "c", "position": 2 }], "list_link": "http://www.example.com/lists/1" } """
  • 43. Items API Scenario: Moving an element to the top Given I call "/lists/1/items.json" in POST with: ... And I call "/lists/1/items.json" in POST with: ... When I call "/lists/1/items/2/move.json" in PUT with: """ { "position": 0 } Let’s see some code! """ Then the JSON should be: """ { "items": [{ "name": "b", "position": 0 }, { "name": "Insert your items!", "position": 1 }, { "name": "c", "position": 2 }], "list_link": "http://www.example.com/lists/1" } """
  • 44. Do we need an admin panel?
  • 45. Do we need an admin panel?
  • 46. Do we need an admin panel? Put in your Gemfile: gem 'activeadmin' gem 'meta_search', '>= 1.1.0.pre' Then run: $ bundle install $ rails g active_admin:install $ rails g active_admin:resource users $ rails g active_admin:resource lists $ rails g active_admin:resource items $ rake db:migrate
  • 47. Do we need an admin panel? Put in your Gemfile: Let’s see some code! gem 'activeadmin' gem 'meta_search', '>= 1.1.0.pre' Then run: $ bundle install $ rails g active_admin:install $ rails g active_admin:resource users $ rails g active_admin:resource lists $ rails g active_admin:resource items $ rake db:migrate
  • 48. Build a JS App!
  • 49. Do you like Spaghetti Code? JavaScript Apps are often a mess We mix logic with presentation with persistance. Packaging is hard. http://www.flickr.com/photos/mpirotta/4944504834
  • 50. What we want http://www.flickr.com/photos/bob_u/208396193
  • 51. Rethinking MVC MVC pattern was introduced with Smalltalk too many years ago. In “true” MVC the “View” updates itself when the model changes. We could not port it to the Rails world. http://www.flickr.com/photos/wbaiv/2554954565
  • 52. Build a JS App the Rails Way! Backbone.js: MVC in the browser Rails asset pipeline concatenate and minifies our JS automatically We can even write our app in CoffeeScript: it works out of the box.
  • 53. Build a JS App the Rails Way! Backbone.js: MVC in the browser to Rails asset pipeline concatenate the code.. again? and minifies our JS automatically We can even write our app in CoffeeScript: it works out of the box.
  • 55. We are late, the #rubyday crew are kicking me out! http://www.flickr.com/photos/oneaustin/1261907803
  • 56. TL;DR http://www.flickr.com/photos/evilaugust/3307382858
  • 57. TL;DR Mobile Apps need an API Ruby on Rails is good for writing APIs You can build nice admin interfaces with ActiveAdmin You can craft Javascript Apps easily using the asset pipeline.
  • 60. www.mavigex.com www.wemobi.it

Editor's Notes