我视图中的Ruby代码在heroku上崩溃了我的rails应用程序。同时它也在开发中。我正在使用HAML。
= @sold
- @sold.each do |x|
%p lorem
它突破第二行 - @sold.each do |x|
,无论@sold等于nil还是有值。你们有什么线索的原因吗?
控制器:
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 :(得分:6)
尝试更改此行:
@sold = @user.products.where("quantity == ?", 0)
对此:
@sold = @user.products.where(quantity: 0)
我认为问题是因为你试图在PostgreSQL中使用double equals作为匹配器,但它并不支持它。如果要检查那里是否相等,则应使用=
。