Topic: Refactor controller method that is shared accross 2 others
this is actually a basic question but i had some errors when i tried it out so i figured i'd ask here.
i have 3 controllers Cat, Dog and Mouse.
Cat, Dog and Mouse have a common method in them: eat
here's a sample of Cat:
class Cat < ApplicationController
# do eat functionality
@cat = Cat.find(params[:id])
@cat.food = "Fish"
# some CRUD actions here
eat doesn't have it's own view.
how can i refactor this into a common controller file that the Cat, Dog and Mouse can share?
suppose the eat method did have a view, then can i refactor them the same way?