I have DRY'd up the controller code using inheritance.
class MastersController < ApplicationController
def index
...
...
end
...
...
end
class ItemsController < MastersController
end
Now I have added a custom action to the MastersController
class MastersController < ApplicationController
def index
...
...
end
...
...
def clone
...
...
end
end
I have added the routes for item
resources :items do
get :clone
end
Now when I try to access myapp.dev/items/1/clone, I get the error
AbstractController::ActionNotFound at /items/1/clone
The action 'clone' could not be found for ItemsController
If I add the 'clone' action in ItemsController the error goes away.
class ItemsController < MastersController
def clone
...
...
end
end
How do I abstract a custom action in Rails Controller?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With