比如模型是这样:
[code="ruby"]
class Province < ActiveRecord::Base
has_many :cities
end
class City < ActiveRecord::Base
has_many :factories
belongs_to :province
end
class Factory < ActiveRecod::Base
has_many :products
belongs_to :city
end
class Product < ActiveRecord::Base
belongs_to :factory
end
[/code]
是不是应该直接弄一个:through来表示Product和Province之间的关联呢?可是这样的:through怎么写啊?我试了半天都不中啊……
主要我是想查找Product表里面,Province包含某字符的记录,不用:through而用别的方法,能达到目的也行……