action controller

15
ActionController by these guys & gal Stephen(itis) Fab(ulous) (Toyota)Avalon Phase 3 @devbootcamp Spring 2013 Monday, May 13, 13

Upload: stephen-nguyen

Post on 21-Jan-2018

296 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Action controller

ActionControllerby these guys & gal

Stephen(itis) Fab(ulous) (Toyota)Avalon

Phase 3 @devbootcamp Spring 2013

Monday, May 13, 13

Page 2: Action controller

What is ActionController?MVC

Monday, May 13, 13

Page 3: Action controller

Like a switchboard operatorRoutes

Controller

Monday, May 13, 13

Page 4: Action controller

Differences

• Route is included and defined

• View is defined by user

• Manually created

RailsSinatra

• Route is not included

• Rendered view is defined by convention

• Actions can be automatically generated by scaffolding

Monday, May 13, 13

Page 5: Action controller

So where are the routes and views?

get ‘/posts’ => post#index

app/views/posts/index.html.erb

/app/config/routes.rb

Monday, May 13, 13

Page 6: Action controller

Convention over configuration

• With Sinatra you are free to name and define your controller actions/routes

• examples:

• get “/showindex” or post “/creatething”

• “In Rails there should be no guessing to what a controller action is doing” - Shadi

Monday, May 13, 13

Page 7: Action controller

CRUD ACTIONS

• CREATE

• READ

• UPDATE

• DESTROY

Monday, May 13, 13

Page 8: Action controller

Controller: light on logic

Monday, May 13, 13

Page 9: Action controller

READ

Monday, May 13, 13

Page 10: Action controller

CREATE

Monday, May 13, 13

Page 11: Action controller

UPDATE

Monday, May 13, 13

Page 12: Action controller

DESTROY

Monday, May 13, 13

Page 13: Action controller

Filters

Monday, May 13, 13

Page 14: Action controller

Some more for you to explore

• Sessions

• Flashes

• Rendering xml and json

Monday, May 13, 13

Page 15: Action controller

Questions??

Monday, May 13, 13