I’ve got a Post model. The Post could be a type of Question, Answer or Comment(similar to StackOverflow structure). For now on controller is handling requests to CRUD any type of a Post. There is a convention that controllers need to be thin in Rails, and my controller doesn’t seem to follow this one because of the case statements(Post types selection and handling) in any action. So my question: is there a way to reorganize or(even better) divide Post controller to handle Question, Answer and Comment separately, but use a common Post views? Any links/examples would be appreciated.
I’ve got a Post model. The Post could be a type of Question, Answer
Share
You can just inherit one controller from another:
One common controller:
Then in each controller:
And all the views you can keep in the folder
posts, or those which are different into their own folders