Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails,无法通过HABTM 获取值;关系_Ruby On Rails_Ruby_Activerecord_Ruby On Rails 5 - Fatal编程技术网

Ruby on rails Rails,无法通过HABTM 获取值;关系

Ruby on rails Rails,无法通过HABTM 获取值;关系,ruby-on-rails,ruby,activerecord,ruby-on-rails-5,Ruby On Rails,Ruby,Activerecord,Ruby On Rails 5,我有两个具有HABTM关系的模型,如: font.rbwith has_and_belongs_to_many :personas 和persona.rb has_and_belongs_to_many :fonts 我试着让所有的字体都链接到一个特定的人物角色 Font.includes(:personas).where(persona: persona) 但是我得到一个错误:SQLite3::SQLException:没有这样的列:font.persona 有什么建议吗

我有两个具有HABTM关系的模型,如:

font.rb
with

  has_and_belongs_to_many :personas
persona.rb

  has_and_belongs_to_many :fonts
我试着让所有的字体都链接到一个特定的人物角色

    Font.includes(:personas).where(persona: persona)
但是我得到一个错误:
SQLite3::SQLException:没有这样的列:font.persona

有什么建议吗?

试试:

Font.includes(:personas).where("personas.id": persona.id)
或更简单:

persona.fonts

persona.font
我想我什么都试过了,除了这个!谢谢