2013-10-21 40 views
0

我認爲Ruby代碼在heroku上崩潰了我的rails應用程序。同時它在開發中工作。我正在使用HAML。Rails:我的ruby代碼破解heroku

= @sold 
    - @sold.each do |x| 
     %p lorem 

它突破上第二線- @sold.each do |x|不管@sold等於零,或者如果它具有的值。你們有什麼線索爲什麼?

控制器:

def activity 
    @user = current_user 
    @selling = @user.products.where("quantity != ?", 0) 
    @sold = @user.products.where("quantity == ?", 0) 
    end 

編輯: Heroku的日誌說

"HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. 

2013-10-21T03:21:40.646768+00:00 app[web.1]:  21:   %p one 
2013-10-21T03:21:40.646570+00:00 app[web.1]:  20:   - @sold.each do |x| 
2013-10-21T03:21:40.646570+00:00 app[web.1]:  17:    %button Status 
2013-10-21T03:21:40.646570+00:00 app[web.1]:  18:  %tbody 
2013-10-21T03:21:40.646570+00:00 app[web.1]:  19:   = @sold 
2013-10-21T03:21:40.646768+00:00 app[web.1]: app/views/users/activity.html.haml:20:in `_app_views_users_activity_html_haml___1193554036748909609_69954007105480 
+0

'@ sold'的類型是什麼? – josh

+0

您是否確認在Heroku上運行的Ruby版本與您的本地版本相同? – Vidya

+0

@AlainGoldman:HINT行上面是否有任何額外的內容?請向我們展示此消息上方和下方的20行。 –

回答

6

嘗試改變這一行:

@sold = @user.products.where("quantity == ?", 0) 

要這樣:

@sold = @user.products.where(quantity: 0) 

我認爲這個問題是因爲你試圖在PostgreSQL中使用double equals作爲匹配器,但它不支持這一點。如果你想檢查平等,你應該使用=

+0

好吧,讓我推它到heroku檢查 –

+3

或使用漂亮的AR哈希語法,例如。 '在哪裏(數量:0)' – sevenseacat

+0

就是這樣。這是一個驚人的觀點,謝謝!兩分鐘後我會將其標記爲正確。謝謝 !!!! –