Rails best practices - Parameter or polymorphic model? -


i have 2 models : ownership , loan.

in order validate transaction, use boolean on both models : current, agreed, available. may redundant. i'm asking myself if should create model, let's call status, 3 booleans, , add polymorphic associations ownership , loan.

what think ? should delete boolean both models , create polymorphic model contains each boolean ? or should keep way ?

i not think need polymorphic association here, moving fields separate model sounds idea since appears description can simple lookup table.

i create status model , define 3 attributes such:

# schema information # id     :integer   not null, primary key # status :string(8) not null  #  class status < activerecord::base   current = find_by_status('current')   agreed = find_by_status('agreed')   available = find_by_status('available') end 

then in ownership , loan models add status_id field hold's status.id. , access these status constants status::current , on.


Comments