3

나는 프로덕션 오더를 관리 할 앱을 구현 중입니다. 각 주문에는 인쇄 및 굽힘을 포함한 많은 프로세스 (단계)가 있습니다. 쉽게 공통 + 특정 속성에 액세스 할 수 있도록상속 접근 : STI? MTI? 또는 간단한 다형성 연관성?

create_table :stages do |t| 
    t.integer :number 
    t.decimal :roll_width 
    t.decimal :quantity 
    t.string :comments 
    t.boolean :finished 

    t.timestamps 
end 

create_table :printing_stages do |t| 
    t.integer :color 
    t.decimal :technical_card 

    t.timestamp 
end 

create_table :bending_stages do |t| 
    t.decimal :flap_width 
    t.boolean :seal_distance 

    t.timestamps 
end 

내가 위해 여기에 따르도록 PROPPER 접근 방식에 대해 확실하지 않다 : 모든 프로세스는 수량과 주석으로 일반적인 특성, 그리고 어떤 단계 별 사람이 .

STI를 사용하는 경우 일부 단계에 10 개 이상의 특정 속성이 있으므로 거대한 sigle 테이블로 끝납니다.

내가 같이 다형성 연결을 사용하는 경우 :

class Stage < ActiveRecord::Base 
    belongs_to :stageable, :polymorphic => true 
end 

class SlittingStage ActiveRecord::Base 
    has_one :stage, :as => stageable 
end 

class PrintingStage ActiveRecord::Base 
    has_one :stage, :as => stageable 
end 

그때는 될 수 있기 때문에 오히려 복잡하고 너무 우아하지 IMHO는,이다 printing_stage.stage.comments와 같은 인쇄 단계의 의견 예를 들어 액세스해야합니다.

그리고 마지막으로, MTI 사용의 영향과 결과에 대해 확신 할 수 없습니다.

조언을 해줄 수 있습니까?

답변

2

이 여인은 내가 할 수있는 것보다 더 잘한다고 말합니다. 당신이 20 분 정도에 뛰어 내리는 것은 당신의 대답이있는 곳입니다.

Make a Mess by Sandi Metz