Additional RESTful actions

suggest change
resources :photos do
  member do
    get 'preview'
  end
  collection do
    get 'dashboard'
  end
end

This creates the following routes in addition to the default 7 RESTful routes:

get       '/photos/:id/preview',          to: 'photos#preview'
get       '/photos/dashboard',            to: 'photos#dashboard'

The same routes can be declared on one line each:

resources :photos do
  get 'preview', on: :member
  get 'dashboard', on: :collection
end

You can also add an action to the /new path:

resources :photos do
  get 'preview', on: :new
end

Which will create:

get       '/photos/new/preview',          to: 'photos#preview'

Be mindful when adding actions to your RESTful routes. You may be missing another resource.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents