为什么我得到错误没有这样的列? [英] Why i get error no such column?

查看:48
本文介绍了为什么我得到错误没有这样的列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有公司模型和模型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.

这篇关于为什么我得到错误没有这样的列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆