小编Hen*_*nry的帖子

ActiveRecord :: StatementInvalid(PG :: SyntaxError:ERROR:语法错误位于或接近"."

我不确定为什么我的查询在localhost上运行但在服务器上失败.当我尝试创建一个路由到QuizzesController #new的测验时会发生这种情况

# GET /quizzes/new
  def new
    @quiz = current_user.quizzes.new
  end
Run Code Online (Sandbox Code Playgroud)

这是查询:

SELECT COUNT(*) FROM "questions" INNER JOIN "question_categories" ON "question_categories"."question_id" = "questions"."id" WHERE "questions"."deleted_at" IS NULL AND (`question_categories`.`category_id` IN (87,1))

(1.0ms)  ROLLBACK
Completed 500 Internal Server Error in 58ms (ActiveRecord: 13.4ms)
Run Code Online (Sandbox Code Playgroud)

我得到了一个错误.

ActiveRecord::StatementInvalid (PG::SyntaxError: ERROR:  syntax error at or near "." LINE 1: ...s"."deleted_at" IS NULL AND (`question_categories`.`category...
Run Code Online (Sandbox Code Playgroud)

quiz.rb在创建之前我会运行build_parts,它应该随机抓取问题并将它们放入测验中.class Quiz <ActiveRecord :: Base belongs_to:user belongs_to:subject has_many:quiz_categories has_many:categories,through :: quiz_categories has_many:quiz_parts

  accepts_nested_attributes_for :categories
  accepts_nested_attributes_for :quiz_parts

  validates :user, :subject, :number_of_questions, presence: …
Run Code Online (Sandbox Code Playgroud)

postgresql activerecord ruby-on-rails

1
推荐指数
1
解决办法
5768
查看次数

标签 统计

activerecord ×1

postgresql ×1

ruby-on-rails ×1