Has and Belongs to Many error - *_development.hunts_tasks' doesn't exist:

送分小仙女□ 提交于 2019-12-01 01:03:40

I suggest you consider switching from has_and_belongs_to_many to has_many :through => tbl

class Hunt < ActiveRecord::Base
  has_many :hunttasks
  has_many :tasks :through => :hunttasks
end

class HuntTask < ActiveRecord::Base

  belongs_to :hunt
  belongs_to :task

class Task < ActiveRecord::Base
  has_many :hunttasks
  has_many :hunts :through => :hunttasks
end

You'll find it more flexible and easier to use in the long term so it's a better place to start.

I don't normally point to api's when folks have questions but in this case the api does actually have good info and examples.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!