Rails PG::SyntaxError: 错误说明

杰里纳尔

我收到一个奇怪的错误。我有客户消息....客户有_许多消息.. 和消息属于_给客户 客户有一个电话栏,一条消息有一个栏。下面的代码假设获取当前客户 ID 并获取电话列,然后根据to查找电话匹配的所有消息然后使用客户 ID 更新所有消息。

我收到这个错误,我没有看到问题。有人能告诉我我做错了什么吗?每个循环都会触发错误。我试图检查@foundmessage_all 但这不起作用。

 PG::SyntaxError: ERROR: syntax error at or near "to" LINE 1: SELECT
 "messages".* FROM "messages" WHERE (to = '2081234567'... ^ : SELECT
 "messages".* FROM "messages" WHERE (to = '2081234567' )

客户/show.rb

 @customer = Customer.find(params[:id])
 tempphone = @customer.phone
 @foundmessage_all = Message.where('to = ? ', tempphone)
       if @foundmessage_all != nil
          @foundmessage_all.each do |t|
          t.update_attribute(:customer_id, @customer.id)
          end
       else
          #other stuff
       end
维杰·阿格拉瓦尔

更改为以下语句:

@foundmessage_all = Message.where(to: tempphone)

如果这不能解决问题,请发布完整的堆栈跟踪。

您也应该检查present?@foundmessage_all,而不是!= nil

if @foundmessage_all.present?

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Rails 4.1.1 w / pg_search-“ PG :: SyntaxError:错误:” AS“或附近的语法错误”错误

来自分类Dev

Rails Devise PG :: SyntaxError:错误:在““”“或附近”的零长度分隔标识符

来自分类Dev

使用rails的PG错误

来自分类Dev

Rails groupdate gem pg错误

来自分类Dev

Rails groupdate gem pg错误

来自分类Dev

ActiveRecord :: StatementInvalid(PG :: SyntaxError:错误:“或”附近的语法错误。

来自分类Dev

PG::SyntaxError: 错误:“PARALLEL”处或附近的语法错误

来自分类Dev

在带有Postgresql的Rails应用程序中使用布尔字段时,为什么会收到ActiveRecord :: StatementInvalid:PG :: SyntaxError:错误?

来自分类Dev

Rails pg gem,安装pg时发生错误

来自分类Dev

gem 偏执狂 - PG::SyntaxError:错误:“FROM”处或附近的语法错误

来自分类Dev

Rails迁移-PG ::错误:错误:整数的无效输入语法:“”

来自分类Dev

rails:HABTM和ActiveRecord错误(PG :: UndefinedTable:错误:缺少FROM ...)

来自分类Dev

Rails:PG :: UndefinedTable:错误:关系“ ...”不存在

来自分类Dev

Rails 4:嵌套属性和PG :: NotNullViolation错误

来自分类Dev

在Rails中使用Postgres UUID时避免PG :: InvalidTextRepresentation错误

来自分类Dev

Rails PG :: UndefinedTable:错误:缺少表的FROM子句条目

来自分类Dev

Rails:PG :: InsufficientPrivilege:错误:关系schema_migrations的权限被拒绝

来自分类Dev

Heroku上的Rails应用出现奇怪的PG :: UndefinedTable错误

来自分类Dev

Rails PG :: ForeignKeyViolation:错误:在表上插入或更新

来自分类Dev

pg gem的Rails s和bundle安装错误?

来自分类Dev

Rails:PG :: InsufficientPrivilege:错误:关系schema_migrations的权限被拒绝

来自分类Dev

PG :: UndefinedTable错误在Rails Heroku上的红宝石

来自分类Dev

Heroku / Rails:PG ::未定义表:在Heroku Rails迁移上不存在错误“ [[tablename]””

来自分类Dev

PG:ConnectBad Rails 4 Postgresql

来自分类Dev

Rails Ransack搜索PG hstore

来自分类Dev

Rails:PG :: NotNullViolation:错误:“ id”列中的空值违反了非空约束

来自分类Dev

频繁的PG :: ConnectionBad:RDS和rails / activerecord的连接关闭错误

来自分类Dev

PG :: UndefinedTable:错误:缺少FROM子句-订购带有“ includes” Rails的关联记录

来自分类Dev

创建表单(简单表单)的问题PG :: NotNullViolation:错误:Rails列中的空值

Related 相关文章

  1. 1

    Rails 4.1.1 w / pg_search-“ PG :: SyntaxError:错误:” AS“或附近的语法错误”错误

  2. 2

    Rails Devise PG :: SyntaxError:错误:在““”“或附近”的零长度分隔标识符

  3. 3

    使用rails的PG错误

  4. 4

    Rails groupdate gem pg错误

  5. 5

    Rails groupdate gem pg错误

  6. 6

    ActiveRecord :: StatementInvalid(PG :: SyntaxError:错误:“或”附近的语法错误。

  7. 7

    PG::SyntaxError: 错误:“PARALLEL”处或附近的语法错误

  8. 8

    在带有Postgresql的Rails应用程序中使用布尔字段时,为什么会收到ActiveRecord :: StatementInvalid:PG :: SyntaxError:错误?

  9. 9

    Rails pg gem,安装pg时发生错误

  10. 10

    gem 偏执狂 - PG::SyntaxError:错误:“FROM”处或附近的语法错误

  11. 11

    Rails迁移-PG ::错误:错误:整数的无效输入语法:“”

  12. 12

    rails:HABTM和ActiveRecord错误(PG :: UndefinedTable:错误:缺少FROM ...)

  13. 13

    Rails:PG :: UndefinedTable:错误:关系“ ...”不存在

  14. 14

    Rails 4:嵌套属性和PG :: NotNullViolation错误

  15. 15

    在Rails中使用Postgres UUID时避免PG :: InvalidTextRepresentation错误

  16. 16

    Rails PG :: UndefinedTable:错误:缺少表的FROM子句条目

  17. 17

    Rails:PG :: InsufficientPrivilege:错误:关系schema_migrations的权限被拒绝

  18. 18

    Heroku上的Rails应用出现奇怪的PG :: UndefinedTable错误

  19. 19

    Rails PG :: ForeignKeyViolation:错误:在表上插入或更新

  20. 20

    pg gem的Rails s和bundle安装错误?

  21. 21

    Rails:PG :: InsufficientPrivilege:错误:关系schema_migrations的权限被拒绝

  22. 22

    PG :: UndefinedTable错误在Rails Heroku上的红宝石

  23. 23

    Heroku / Rails:PG ::未定义表:在Heroku Rails迁移上不存在错误“ [[tablename]””

  24. 24

    PG:ConnectBad Rails 4 Postgresql

  25. 25

    Rails Ransack搜索PG hstore

  26. 26

    Rails:PG :: NotNullViolation:错误:“ id”列中的空值违反了非空约束

  27. 27

    频繁的PG :: ConnectionBad:RDS和rails / activerecord的连接关闭错误

  28. 28

    PG :: UndefinedTable:错误:缺少FROM子句-订购带有“ includes” Rails的关联记录

  29. 29

    创建表单(简单表单)的问题PG :: NotNullViolation:错误:Rails列中的空值

热门标签

归档