2017-02-09 58 views

回答

0

我做这样的事情在我的应用程序

def Foo do 
    schema "foos" do 
    field :name, :string 

    has_many :bars_foos 
    end 
end 

def Bar do 
    schema "bars" do 
    field :other, :integer 

    has_many :bars_foos 
    end 
end 

def BarFoo do 
    schema "bars_foos" do 
    field :size, :integer 

    belongs_to :bars 
    belongs_to :foos 
    end 
end 

这使用has_manybelongs_to而不是many_to_many下列操作之一,但它实现了非常类似的东西。如果您需要直接链接到其他数据集,则还可以使用和through

+0

感谢您的建议。我也会用这种方法! –