簡體   English   中英

PG ::部署到heroku時出錯

[英]PG:: Error when deployed to heroku

將應用程序推送到heroku時,我在應用程序中收到一個奇怪的錯誤。 該應用程序可以在我的本地計算機上正常運行。 我不知道我在本地使用Mysql的原因嗎?

這是我得到的錯誤:

2012-07-24T17:14:52+00:00 app[web.1]: ActionView::Template::Error (PG::Error: ERROR:  argument of AND must be type boolean, not type integer
2012-07-24T17:14:52+00:00 app[web.1]: : SELECT COUNT(*) FROM "users" INNER JOIN "articles_users" ON "users"."id" = "articles_users"."user_id" WHERE "articles_users"."article_id" = 64 AND (1)):
2012-07-24T17:14:52+00:00 app[web.1]:     9:            <span>
2012-07-24T17:14:52+00:00 app[web.1]:     10:           <a data-action="like" data-id="<%= a.id %>" >
2012-07-24T17:14:52+00:00 app[web.1]:     11:           <%if user_signed_in?%>
2012-07-24T17:14:52+00:00 app[web.1]:     12:                   <%if a.likes.where(user_id = current_user.id).size == 0%>
2012-07-24T17:14:52+00:00 app[web.1]:     13:                           <%=image_tag("star.png", :width => "37", :height => "36", "data-action" => "star")%></a><span data-action="likes" style="vertical-align:10px; padding:8px;">
2012-07-24T17:14:52+00:00 app[web.1]:     14:                   <%else%>
2012-07-24T17:14:52+00:00 app[web.1]:     15:                           <%= image_tag("star-yellow.png", :width => "37", :height => "36", "data-action" =>"star")%></a><span data-action="likes" style="vertical-align:10px; padding:8px;">

這里離我的看法的代碼:

<a data-action="like" data-id="<%= a.id %>" >
    <%if user_signed_in?%>  
        <%if a.likes.where(user_id = current_user.id).size == 0%>   
            <%= image_tag("star.png", :width => "37", :height => "36", "data-action" => "star")%></a><span data-action="likes" style="vertical-align:10px; padding:8px;">
        <%else%>
            <%= image_tag("star-yellow.png", :width => "37", :height => "36", "data-action" => "star")%></a><span data-action="likes" style="vertical-align:10px; padding:8px;">
        <%end%>

怎么回事錯在這里? 提前致謝!

您應該像這樣修改where方法。

a.likes.where(:user_id => :current_user.id)

a.likes.where(user_id = current_user.id)

我認為這會起作用。

我變了

<%if a.likes.where(user_id = current_user.id).size == 0%> 

<%if !a.likes.include?(current_user)%>

現在它可以正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM