Making a ruby on rails application for a class, and we are not allowed to use the resources keyword, so my routes file looks like this:
School::Application.routes.draw do
# Routes for departments
get "depts", :to=>"depts#index"
get "depts/new", :to=>"depts#new"
post "depts", :to=>"depts#create"
get "depts/:id", :to=>"depts#show"
get "depts/:id/edit", :to=>"depts#edit"
put "depts/:id", :to=>"depts#update"
delete "depts/:id", :to=>"depts#destroy"
end
There is a problem when I try to get to the edit page, and its because I don’t know the correct ‘:as’ fields for the routes and can’t seem to find them anywhere. Can someone tell me what they would be if I had used the following line?
resource :depts
Thanks.
You could read the guide on Routing:
http://guides.rubyonrails.org/routing.html
If you are lazy, ctrl+F “resources :photos”
UPDATE: for the keyword
:aswithresourceshttp://guides.rubyonrails.org/routing.html#nested-names
OR
http://guides.rubyonrails.org/routing.html#overriding-the-named-helpers
EVEN BETTER: use of
:aswith custom actionhttp://guides.rubyonrails.org/routing.html#naming-routes