What is the design pattern for subclassing a model?

I have a model:

class Item < ActiveRecord::Base 

The item has the 'store' property

Based on the value of the store, I would like the Item object to have different behavior for certain methods.

Is there a common design pattern for Rails? How is this done purely without a large if-else statement in methods?

+4
source share
1 answer

Usually through Single Page Inheritance .

+7
source

Source: https://habr.com/ru/post/1343244/


All Articles