January 2012
Intermediate to advanced
336 pages
8h 12m
English
It may be tempting at this point to run a Rails generator to generate the controller, views, helpers, tests, and who knows what other files. We’ll resist this temptation and implement the bare minimum by hand. This way, we don’t end up with a lot of code that isn’t tested and that we might not even need.
Let’s map our controller to config/routes.rb:
| rails/10/config/routes.rb | |
| | Squeaker::Application.routes.draw do |
| | resources :users |
| | end |
Add app/controllers/users_controller.rb:
| rails/10/app/controllers/users_controller.rb | |
| | class UsersController < ApplicationController |
| | def show |
| | end |
| | end |
And a view in app/views/users/show.html.erb with some temporary content:
| rails/10/app/views/users/show.html.erb ... |
Read now
Unlock full access