jakehschwartz
jakehschwartz

Reputation: 1005

What routes are made using 'resources' keyword?

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.

Upvotes: 0

Views: 2257

Answers (2)

MrYoshiji
MrYoshiji

Reputation: 54892

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 :as with resources

http://guides.rubyonrails.org/routing.html#nested-names

OR

http://guides.rubyonrails.org/routing.html#overriding-the-named-helpers

EVEN BETTER: use of :as with custom action

http://guides.rubyonrails.org/routing.html#naming-routes

Upvotes: 1

shivashankar
shivashankar

Reputation: 1177

In addition, you can find how the routes will be by using the following command

  rake routes

which list out all the configured routes with http methods

Upvotes: 0

Related Questions