Rails and Resources
Bart Zonneveld
Bart!

Dean


Sjoerd!

Niels!

Programmer

Designer

Programmer

Project Lead

http://madebyhiro.com
Uitzending Gemist
± 600.000 visitors / day

± 4.000 req / min (10k peak)

!

!

± 700.000 videos / day

230 ms avg respons...
Amazon.com!
Let’s buy a book about Ruby on Rails
Amazon.com!
Let’s buy a book about Ruby on Rails

•

Get a list of all books
Amazon.com!
Let’s buy a book about Ruby on Rails

•

Get a list of all books

•

Get a specific book
Amazon.com!
Let’s buy a book about Ruby on Rails

•

Get a list of all books

•

Get a specific book
Amazon.com!
Let’s buy a book about Ruby on Rails

•

Get a list of all books

•

Get a specific book

•

Put the book in my...
Amazon.com!
Let’s buy a book about Ruby on Rails

•

Get a list of all books

•

Get a specific book

•

Put the book in my...
Amazon.com!
Let’s buy a book about Ruby on Rails

•

Get a list of all books

•

Get a specific book

•

Put the book in my...
Amazon.com!
Let’s buy a book about Ruby on Rails

•

Get a list of all books

•

Get a specific book

•

Put the book in my...
Amazon.com!
Let’s buy a book about Ruby on Rails

•

Get a list of all books

•

Get a specific book

•

Put the book in my...
Amazon.com!
Let’s buy a book about Ruby on Rails

•

Get a list of all books

•

Get a specific book

•

Put the book in my...
Amazon.com!
Let’s buy a book about Ruby on Rails

•

Get a list of all books

•

Get a specific book

•

Put the book in my...
Amazon.com!
Let’s buy a book about Ruby on Rails
•

Get a list of all books

•

Get a specific book

•

Put the book in my ...
Amazon.com!
Let’s buy a book about Ruby on Rails
•

Get a list of all books

•

Get a specific book

•

Put the book in my ...
Amazon.com!
Let’s buy a book about Ruby on Rails

Verb

Noun

GET

books

PUT

cart

DELETE

book

POST

money
Amazon books
Books! !

!

!

! /books!

! Best sellers

/books/best_sellers!

! Hardcover

/books/hardcover

Sale

/books/...
Top rated books!

/books/top_rated
Top rated books!

/books/top_rated.json
!

{

'books' : [

...

{

id: '3487',

title: 'Agile Web Development with Rails 4...
Top rated books!

/books/3487.json

!

{

id: '3487',

title: 'Agile Web Development with Rails 4',

authors: [ 'Sam Ruby'...
Amazon.rb
!

Amazon.routes do



resources :books



end
Amazon.rb
!

Amazon.routes do



resources :books do
collection :top_rated
end


end
Amazon.routes do

resources :books do
collection :top_rated

Amazon.rb

end
end

Prefix Verb
books GET

URI Pattern

Contr...
Amazon.routes do

resources :books do
collection :top_rated

Amazon.rb

end
end

Prefix Verb
books GET

URI Pattern

Contr...
REpresentational State Transfer

Roy Fielding
Architectural Styles and
the Design of Network-based
Software Architectures ...
REpresentational State Transfer

“How I Explained REST to My Wife”
Ryan Tomayko

tiny.cc/rest_rails
Upcoming SlideShare
Loading in …5
×

Rails and Resources - RailsGirls Leiden

280 views

Published on

  • Be the first to comment

  • Be the first to like this

Rails and Resources - RailsGirls Leiden

  1. 1. Rails and Resources Bart Zonneveld
  2. 2. Bart! Dean
 Sjoerd! Niels! Programmer Designer Programmer Project Lead http://madebyhiro.com
  3. 3. Uitzending Gemist ± 600.000 visitors / day ± 4.000 req / min (10k peak) ! ! ± 700.000 videos / day 230 ms avg response
  4. 4. Amazon.com! Let’s buy a book about Ruby on Rails
  5. 5. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books
  6. 6. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books • Get a specific book
  7. 7. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books • Get a specific book
  8. 8. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books • Get a specific book • Put the book in my cart
  9. 9. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books • Get a specific book • Put the book in my cart • Get the list of all books
  10. 10. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books • Get a specific book • Put the book in my cart • Get the list of all books • Get a specific book
  11. 11. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books • Get a specific book • Put the book in my cart • Get the list of all books • Get a specific book
  12. 12. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books • Get a specific book • Put the book in my cart • Get the list of all books • Get a specific book • Put the book in my cart
  13. 13. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books • Get a specific book • Put the book in my cart • Get the list of all books • Get a specific book • Put the book in my cart • Get the contents of my cart
  14. 14. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books • Get a specific book • Put the book in my cart • Get the list of all books • Get a specific book • Put the book in my cart • Get the contents of my cart • Delete a book from my cart
  15. 15. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books • Get a specific book • Put the book in my cart • Get the list of all books • Get a specific book • Put the book in my cart • Get the contents of my cart • Delete a book from my cart • Post money to Amazon
  16. 16. Amazon.com! Let’s buy a book about Ruby on Rails • Get a list of all books • Get a specific book • Put the book in my cart • Get the list of all books • Get a specific book • Put the book in my cart • Get the contents of my cart • Delete a book from my cart • Post money to Amazon
  17. 17. Amazon.com! Let’s buy a book about Ruby on Rails Verb Noun GET books PUT cart DELETE book POST money
  18. 18. Amazon books Books! ! ! ! ! /books! ! Best sellers /books/best_sellers! ! Hardcover /books/hardcover Sale /books/sale Top rated /books/top_rated
  19. 19. Top rated books! /books/top_rated
  20. 20. Top rated books! /books/top_rated.json ! {
 'books' : [
 ...
 {
 id: '3487',
 title: 'Agile Web Development with Rails 4',
 authors: [ 'Sam Ruby', 'Dave Thomas', 'David Heinemeier Hansson' ],
 price: '$ 26.37',
 rating: '4.2'
 }
 ...
 ]
 }
  21. 21. Top rated books! /books/3487.json ! {
 id: '3487',
 title: 'Agile Web Development with Rails 4',
 authors: [ 'Sam Ruby', 'Dave Thomas', 'David Heinemeier Hansson' ],
 price: '$ 26.37',
 rating: '4.2'
 }
  22. 22. Amazon.rb ! Amazon.routes do
 
 resources :books
 
 end
  23. 23. Amazon.rb ! Amazon.routes do
 
 resources :books do collection :top_rated end 
 end
  24. 24. Amazon.routes do
 resources :books do collection :top_rated Amazon.rb end end Prefix Verb books GET URI Pattern Controller#Action /books books#index /books/top_rated books#top_rated /books books#create /books/new books#new /books/:id/edit books#edit book GET /books/:id books#show PUT /books/:id books#update top_rated_books GET POST new_book GET edit_book GET DELETE /books/:id books#destroy
  25. 25. Amazon.routes do
 resources :books do collection :top_rated Amazon.rb end end Prefix Verb books GET URI Pattern Controller#Action /books books#index /books/top_rated books#top_rated /books books#create /books/new books#new /books/:id/edit books#edit book GET /books/:id books#show PUT /books/:id books#update top_rated_books GET POST new_book GET edit_book GET DELETE /books/:id books#destroy
  26. 26. REpresentational State Transfer Roy Fielding Architectural Styles and the Design of Network-based Software Architectures (2000)
  27. 27. REpresentational State Transfer “How I Explained REST to My Wife” Ryan Tomayko tiny.cc/rest_rails

×