我正在将rails应用程序从sqlite转换为postgres,这样我就可以使用heroku进行部署。我安装了postgres并运行了迁移,但是当我尝试运行一个查询来查找与某个房屋相关联的所有室友时,我得到了以下错误
PG::Error: ERROR: operator does not exist: character varying = integer
LINE 1: SELECT COUNT(*) FROM "mates" WHERE "mates"."house_id" = 1
^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT COUNT(*) FROM "mates" WHERE "mates"."house_id" = 1此错误源于您在添加房屋后被重定向至创建和管理员的注册视图。以下是视图代码:
Extracted source (around line #4):
1: <div class="container">
2: <div class="row">
3: <div class="span5 offset3">
4: <% if current_house.mates.empty? %>
5: <h2>Add an Administrator</h2>
6: <% else %>
7: <h2>Add a New Housemate</h2>谢谢你的帮助!
发布于 2013-07-15 05:20:42
转到add_house_id_to_mates迁移并将第3行从字符串更改为整数。在此之后,删除20130628212206_change_type_of_house_id_in_house.rb迁移。
从零开始运行迁移:
rake db:drop db:create db:migrate
https://stackoverflow.com/questions/17643701
复制相似问题