为什么我得到错误没有这样的列?

编程入门 行业动态 更新时间:2024-10-28 05:25:53
本文介绍了为什么我得到错误没有这样的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有公司模型和模型Invintaton,公司可以邀请其他公司发送消息,现在我只需要显示确认消息的公司

I have Company model and model Invintaton, Companies can invite other companies for messaging and now i need show only companies who confirm the messaging

class Company < ActiveRecord::Base has_many :sent_invitations, class_name: 'Invintation', foreign_key: 'sender_id' has_many :invitation_recipients, through: :sent_invitations, source: :recipient has_many :incoming_invitations, class_name: 'Invintation', foreign_key: 'recipient_id' has_many :invitation_senders, through: :incoming_invitations, source: :sender end class Invintation < ActiveRecord::Base belongs_to :recipient, class_name: 'Company', foreign_key: 'recipient_id' belongs_to :sender, class_name: 'Company', foreign_key: 'sender_id' end class MessagesController < ApplicationController def new @company = Company.find(params[:company_id]) @message = @company.sent_messages.new @recipients = Company.joins(:invitation_recipients).where(invitation_recipients: {sender_id: @company.id, confrm: true}) end end

但我得到错误 SQLite3::SQLException: no such column: sent_invitations.confrm: SELECT "companies".* FROM "companies" INNER JOIN "invintations" ON "invintations"."sender_id" = "companies"."id" WHERE "sent_invitations"."confrm" = 't'

but i get error SQLite3::SQLException: no such column: sent_invitations.confrm: SELECT "companies".* FROM "companies" INNER JOIN "invintations" ON "invintations"."sender_id" = "companies"."id" WHERE "sent_invitations"."confrm" = 't'

我知道这种方式只显示发送邀请的公司,这是必要的,并包含邀请

And i know this way show only companies who were sending the invitation , and it is necessary , and included an invitation

推荐答案

您的查询中至少有两个拼写错误:

You have at least two typos in your query:

  • sent_invitations.confrm 而它应该是 sent_invitations.confirm
  • Invintation 而应该是 Invitation
  • sent_invitations.confrm whereas it should be sent_invitations.confirm
  • Invintation whereas it should be Invitation

检查您的代码并修复拼写错误,假设生成的数据库架构没有出现相同的拼写错误.

Review your code and fix the typos, assuming the database schema was not generate with the same spelling errors.

更多推荐

为什么我得到错误没有这样的列?

本文发布于:2023-10-16 22:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498880.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!