糾正錯誤有點麻煩。Rails 3.1。 Heroku PGError:操作符不存在:字符變化=整數
所有的作品在本地機器上都很棒。 在PG上,heroku是錯誤的。
下面是日誌:
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m ActionView::Template::Error (PGEr
ror: ERROR: operator does not exist: character varying = integer
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m LINE 1: ...T "reviews".* FROM "re
views" WHERE "reviews"."trip_id" = 32
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m : SELECT "reviews".* FROM "review
s" WHERE "reviews"."trip_id" = 32):
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m 31: <div style='display:non
e'>
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m 33: <% for review in @tr
ip.reviews %>
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m 34:
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m 32: <div id="inline">
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m HINT: No operator matches the gi
ven name and argument type(s). You might need to add explicit type casts.
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m app/controllers/trips_controlle
r.rb:21:in `show'
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m cache: [GET /trips/32] miss
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m 36: <li> <%= review.conte
nt %> </li>
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m 35: <ul>
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m app/views/trips/show.html.erb:3
3:in `_app_views_trips_show_html_erb__3301405670044045300_69859019468960'
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m Completed 500 Internal Server Err
or in 86ms
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m Parameters: {"id"=>"32"}
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m Processing by TripsController#s
how as HTML
←[32m2012-01-09T19:52:24+00:00 app[web.1]:←[0m Rendered trips/show.html.erb with
in layouts/application (81.8ms)
不能確定確切位置在哪裏,發生了錯誤,以及如何解決它。
reviews.rb
class Review < ActiveRecord::Base
belongs_to :trip
end
class Trip < ActiveRecord::Base
has_many :reviews, :dependent => :destroy
attr_accessible, :reviews_attributes
accepts_nested_attributes_for :reviews, :reject_if => lambda { |a| a[:name].blank? }, :allow_destroy => true
end
show.html.rb
<%= link_to "Read Reviews", '#inline', :id => 'various1', :class => 'review' %>
<div style='display:none'>
<div id="inline">
<% for review in @trip.reviews %>
<ul>
<li> <%= review.content %> </li>
<li> <i> <%= review.name %> </i> </li>
</ul>
<% end %>
</div>
</div>
,混淆我的是,我有兩個其他幾乎相同的車型,但他們的工作很好的事情。
謝謝!
謝謝!它看起來像,我創建模型時輸入錯誤(整數作爲字符串)。 – emilsw 2012-01-09 21:46:58
在本地沒有看到它,因爲sqlite3可以。你是對的,有時間開始在PG之上開發。 – emilsw 2012-01-09 21:51:58
嘿@mu_is_too_short!這是很長的時間;)問題,我很好奇,如果仍然可以用一個字符串做到這一點(如果你真的必須)。 – Trip 2017-08-10 13:18:30