我有像
这样的动作@documents = Document.all.includes(:user, user: :skills, user: :profession)
当我在控制器上运行rubocop时,我得到了这个结果:
controllers/documents_controller.rb:4:75: W: Lint/DuplicatedKey: Duplicated key in hash literal.
@documents = Document.all.includes(:user, user: :skills, user: :profession)
^^^^
我该如何解决这个问题?
答案 0 :(得分:3)
这是一种方式:
Document.all.includes(:user, { user: [:skills, :profession] })