action controller
TRANSCRIPT
ActionControllerby these guys & gal
Stephen(itis) Fab(ulous) (Toyota)Avalon
Phase 3 @devbootcamp Spring 2013
Monday, May 13, 13
What is ActionController?MVC
Monday, May 13, 13
Like a switchboard operatorRoutes
Controller
Monday, May 13, 13
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
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
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
CRUD ACTIONS
• CREATE
• READ
• UPDATE
• DESTROY
Monday, May 13, 13
Controller: light on logic
Monday, May 13, 13
READ
Monday, May 13, 13
CREATE
Monday, May 13, 13
UPDATE
Monday, May 13, 13
DESTROY
Monday, May 13, 13
Filters
Monday, May 13, 13
Some more for you to explore
• Sessions
• Flashes
• Rendering xml and json
Monday, May 13, 13
Questions??
Monday, May 13, 13