나는 파이낸싱> - 이벤트> - 서브 프로그램> - 프로그램과 같은 분노한 연관이 있습니다. 그래서잘못된 소스 리플렉션 매크로 : has_many : through
class Fcp < Program
has_many :fcp_subprograms,
:foreign_key => 'parent_id'
has_many :subprogram_last_actual_financings,
:through => :fcp_subprograms,
:source => :last_actual_financings
class FcpSubprogram < Program
belongs_to :fcp,
:class_name => 'Fcp',
:foreign_key => 'parent_id'
has_many :events,
:foreign_key => 'fcp_id'
has_many :last_actual_financings,
:through => :events,
:source => :last_actual_financings
class Event < ActiveRecord::Base
belongs_to :fcp,
:class_name => 'Fcp',
:foreign_key => 'fcp_id'
belongs_to :fcp_subprogram,
:class_name => 'FcpSubprogram',
:foreign_key => 'fcp_id'
has_many :last_actual_financings,
:class_name => 'ActualFinancing',
:order => 'date DESC',
:limit => 1
나는이 오류
Invalid source reflection macro :has_many :through for has_many :subprogram_last_actual_financings, :through => :fcp_subprograms. Use :source to specify the source reflection.
하지만이에게 얻을 after_initialize 기능에 subprogram_last_actual_financings에 액세스 할 때 코드가 그래서 나는 그들 모두를 통해 프로그램의 last_financings에 대한 액세스를 얻으려면 : 내 연결에서 소스 옵션. 내가 도대체 뭘 잘못하고있는 겁니까? 당신이 얻을 오류가 source_reflection에 관한
self.subprograms.first.events.first.financings.first(:order => 'date DESC')
nested_has_many_through 플러그인 시도 http://github.com/ianwhite/nested_has_many_through 실험적이지만 rails-2.3 브랜치를 사용하십시오. 나는 그것을 시도하지 않았다. 또는 –
재미있는 플러그인! 나는 그것을 시험해 봐야한다 – klew
당신의 충고에 대해 대단히 고마운! – Antiarchitect