resources :peopleoffers those routes (doing rake routes in the Rails console):
people | GET | /people(.:format) | people#index |
POST | /people(.:format) | people#create | |
new_person | GET | /people/new(.:format) | people#new |
edit_person | GET | /people/:id/edit(.:format) | people#edit |
person | GET | /people/:id(.:format) | people#show |
PUT | /people/:id(.:format) | people#update | |
DELETE | /people/:id(.:format) | people#destroy |
class PeopleController < ApplicationController def index # GET end def show # GET end end
there are 5 routes too much. Offering them anyway is misleading and improper.
Those would be sufficient:
people | GET | /people(.:format) | people#index |
person | GET | /people/:id(.:format) | people#show |
resources :people, :only => [:index, :show]generates the 2 required routes to PeopleController#index and PeopleController#show.
Just to mention it, the opposite to :only is :except.
For example:
resources :people, :except => :destroyoffers all standard RESTful routes to the people resources except 'destroy':
people | GET | /people(.:format) | people#index |
POST | /people(.:format) | people#create | |
new_person | GET | /people/new(.:format) | people#new |
edit_person | GET | /people/:id/edit(.:format) | people#edit |
person | GET | /people/:id(.:format) | people#show |
PUT | /people/:id(.:format) | people#update |
Reduce them to the required amount!
Supported by Ruby 2.1.1 and Ruby on Rails 3.2.17
Keine Kommentare:
Kommentar veröffentlichen