belongs_to
方法本身表示什么意思。
引进了哪些方法,表示什么意思。
有什么参数,表示什么意思,使用后有什么效果。
# 关联对象的 id = 2
belongs_to :user, -> { where(id: 2) }
# 同时 join 关联对象的 friends
belongs_to :user, -> { joins(:friends) }
# 关联对象的 game_level 必须大于 level.current
belongs_to :level, ->(level) { where("game_level > ?", level.current) }其它
最后更新于