ore*_*ake 7 activerecord ruby-on-rails-3
Project
has_many :tasks
Task
has_many :invoices, :through => :line_items
has_many :line_items
LineItems
belongs_to :invoice
belongs_to :task
Invoice
has_many :tasks, :through=> :line_item
has_many :line_items
Run Code Online (Sandbox Code Playgroud)
我正在尝试从Project has_many获取关联:发票,:through =>:tasks
当我尝试时,我得到:
源反射宏无效:has_many:for for has_many:invoices,:through =>:tasks.使用:source指定源反射.
如果可能的话,我有点不知所措,如果是这样,如何使用:来源正确
Ryan是对的,这是Rails 3.1支持的.从发行说明中提取:
与a:through选项的关联现在可以使用任何关联作为通关或源关联,包括具有:through选项和has_and_belongs_to_many关联的其他关联.
Src:http://guides.rubyonrails.org/3_1_release_notes.html