내 Rails 3.1 프로젝트에는 많은 연관이있는 모델이 있습니다. 액티브 협회 선언을 사용하여, 나는 다음과 같이 모델 파일로 끝날 :Rails 3.1에서는 많은 모델이있는 ActiveRecord 연관 선언을 어떻게 포맷해야합니까?
이# app/models/some_model.rb
class SomeModel < ActiveRecord::Base
belongs_to :other_model
has_many :more_models
has_many :yet_more_models, :through => :more_models
has_one :another_model, :dependent => :destroy
# ... these declarations continue,
# and continue,
# and continue,
# all the way down to line 32
end
이 빠르게 대단히 추한되고 내 이해/동기 부여/행복을 꺾습니다. 완화하려면 어떻게해야합니까?
- [A] 형식/그룹/특정 방법으로 그들을 들여?
- [B] 다시 생각이
- 는 [C] 그것으로 라이브 가난한 디자인의 증상 일 수 있으므로, 내 데이터 모델을 - 모든 사람의 모델 파일이 방법을 찾습니다.
이러한 자원의 종류에 대한 예를들 수 있습니까? 한 모델의 32 개 협회는 어리석은 것처럼 보입니다. –
[b] 많은 연관이있는 경우 모델에 분명히 잘못된 것이 있습니다. – Henrik
@AshleyWilliams -이 리소스 중 하나는 has_many : authors, : languages, : genres, : categories, : subjects, : translators, : tags, : identifiers, : reviews ... 및이 응용 프로그램과 관련된 기타 , 그리고 그들의 : 협회를 통해. – GladstoneKeep