Thoughts On Rails Generators

A few people I know tweeted to a Rails commit on Github that “Added a generator option to remove the public/index.html file when generating a new Rails application.” The people that tweeted about it said it was about time that this was included.

I think a good option for the scaffold generator would be to explicitly list the routes for each of the created actions in the controller instead of just adding

resources :things

to the config/routes.rb  file.

It would generate this in the config/routes.rb file:

  get '/things' => 'things#index', :as => 'things'
  post '/things' => 'things#create'
  get '/things/new' => 'things#new', :as => 'new_thing'
  get '/things/:id/edit' => 'things#edit', :as => 'edit_thing'
  get '/things/:id' => 'things#show', :as => 'thing'
  put '/things/:id' => 'things#update'
  delete '/things/:id' => 'things#destroy'

I ran rake routes with each, and they matched.

Image from Corpus Agrimensorum Romanorum, a 6th century manuscript on land surveying housed at the Herzog August Library in  Wolfenbüttel. According to Wikipedia, “It is one of the few surviving non-literary and non-religious illuminated manuscripts from late antiquity.” This image is assumed to be allowed under Fair Use.