rails 5 way for having order and includes in has_many



我在轨道3:中有这条线

has_many :balance_lines, :dependent => :destroy, :include => "budget_item", :order => "budget_items.position"

如何将其转换为rails 5?

这是正确的方法:

has_many :balance_lines, -> { order("budget_items.position").includes("budget_item") }, :dependent => :destroy

相关内容

  • 没有找到相关文章

最新更新