hunterp
hunterp

Reputation: 15986

Why is custom action for resource not working?

I have an AppleController

it has a def sliceme method

when I go to: /apple#sliceme

it routes to #index

In my routes.config I have

resources :apples

Why?? And what is the correct route??

Upvotes: 0

Views: 57

Answers (1)

Tom Prats
Tom Prats

Reputation: 7921

Resources will create the CRUD method routes (see here)

If you want to specificity another route you can specify it like so in your routes file:

get "apple/sliceme", to: "apple#sliceme"

Or

resources :apple do
  get :sliceme, on: :collection
end

To check what routes actually exist, run rake routes in the terminal

Upvotes: 1

Related Questions