ruby on rails - Splitting one big ActiveRecord model into multiple models -
i have model called agency
has lot of fields:
name
, state
, promotion
, offers_limit
, promotion_type
etc.
plus info agency imprint imprint_agency_name
, imprint_tax_id
, imprint_city
, imprint_street
, imprint_house_number
, imprint_email
, imprint_phone
etc.
plus fields agency office address (agency can have office or can not have office, info not present).
is thought move imprint info separate related model imprint
, in agency
have has_one :imprint
, imprint
have belongs_to :agency
relations? , creating office
model (with 4-6 fields) related agency
?
as albin said, splitting 1 big model multiple models turned out thing, when came relations, tons of validations, custom validations etc. simpler - better. , easier test.
ruby-on-rails ruby activerecord model
No comments:
Post a Comment