• Save
Enter the app era with ruby on rails (rubyday)
Upcoming SlideShare
Loading in...5
×
 

Enter the app era with ruby on rails (rubyday)

on

  • 5,325 views

 

Statistics

Views

Total Views
5,325
Views on SlideShare
2,208
Embed Views
3,117

Actions

Likes
0
Downloads
0
Comments
0

11 Embeds 3,117

http://www.matteocollina.com 3001
http://localhost 70
http://www.collina.me 19
http://www.linkedin.com 7
http://lanyrd.com 7
https://www.linkedin.com 4
http://hi-tech.leonardo.it 3
https://twitter.com 3
https://www.matteocollina.com 1
http://www.google.fr 1
http://www.google.it 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Enter the app era with ruby on rails (rubyday) Enter the app era with ruby on rails (rubyday) Presentation Transcript

  • Enter the App Erawith 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 toWeb and Mobile Apps Icons by Fasticon
  • We need an API
  • We need an APIWho 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 justtwenty minutes http://www.flickr.com/photos/oneaustin/1261907803
  • What do wewant 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 APIhttp://github.com/mcollina/mcdo
  • Signup APIFeature: 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 APIScenario: 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": ["doesnt match confirmation"] } } """
  • How?
  • How?Ruby on RailsCucumberRSpecJSON-spec
  • How? Ruby on RailsLet’s see some code! Cucumber RSpec JSON-spec
  • Login APIhttp://github.com/mcollina/mcdo
  • Login APIFeature: 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 APIScenario: 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 APIScenario: 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 APIhttp://github.com/mcollina/mcdo
  • Lists APIFeature: Lists API As a MCDO developer In order to develop apps I want to manage a users 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 APIScenario: 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 APIScenario: 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 APIScenario: 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 lists 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 lists 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 APIhttp://github.com/mcollina/mcdo
  • Items APIFeature: Manage a lists items As a developer In order to manipulate the lists 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 APIScenario: 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 needan admin panel?
  • Do we needan admin panel?
  • Do we need an admin panel?Put in your Gemfile: gem activeadmin gem meta_search, >= 1.1.0.preThen 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.preThen 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 likeSpaghetti Code?JavaScript Apps areoften a messWe mix logic withpresentation withpersistance.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 #rubydaycrew 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 interfaceswith ActiveAdmin You can craft Javascript Apps easilyusing the asset pipeline.
  • Any Questions?
  • Matteo CollinaSoftware Engineer@matteocollinamatteocollina.com
  • www.mavigex.com www.wemobi.it
  • Thank You!