Rails has_many with alias name

前端 未结 5 2146
忘掉有多难
忘掉有多难 2020-12-12 09:36

In my User model I could have:

has_many :tasks

and in my Task model:

belongs_to :user

Then, supposing the

5条回答
  •  情深已故
    2020-12-12 10:11

    If you use has_many through, and want to alias:

    has_many :alias_name, through: model_name, source: initial_name
    

提交回复
热议问题