Domain Modeling with REST

Post on 17-May-2015

3,219 views 0 download

Tags:

description

Preview talk for Railsconf 2008 session

transcript

Domain Modeling with REST

Audience Participation!who is using rest?

What is REST?

Resources

Addressability

Representations

Hypermedia

Stateless*

Audience Participation!why care?

Process

Domain

Sorted & Organized - Modeled

?

IdentifyResources

DetermineAvailable Methods

RespectMan in the Middle

Simple

My Pull List

Releases

Issues

Series

Users

Lists

Advanced

Login*

Homepage

Dashboard

Preview

Search

Complex Forms

Collections

Administration

this slide left intentionally blank

Audience Participation!hardest problem you’ve seen?

Rails, Specifically

ActionController::Routing::Routes.draw do |map| map.resources :users # Install the default route as the lowest priority. map.connect ':controller/:action/:id' end

Default Routing

<%= link_to 'Delete', record, :method => 'delete', :confirm => 'Are you sure?' %>

Accessibility

<a href="/records/1" onclick="if (confirm('Are you sure?')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit(); };return false;">Delete</a>

class RecordsController < ApplicationController # GET /records # GET /records.xml def index end

# GET /records/1 # GET /records/1.xml def show end

# ...end

Collections

Audience Participation!where’s rails bitten you?