我希望能够显示帖子,并按照几个标准对它们进行排序,首先是它们对它们的投票数量,第二个是它们创建日期.我不希望显示超过一周的帖子,因此只显示上周的帖子.我试过这样做:
<%= render @posts.sort_by { |post| post.votes.count if post.created_at < 1.week.ago.utc }.reverse %>
Run Code Online (Sandbox Code Playgroud)
但它给了我一个错误的比较NilClass与2失败
我知道代码的工作原理只是通过投票计数来排序帖子,但我也想限制时间,所以有人可以告诉我如何做到这一点.我还是新人,为简单而感到抱歉.
每当我尝试将我的rails应用程序部署到heroku上时,它说
Michael$ heroku create Creating stormy-window-812..... done, stack is bamboo-mri-1.9.2 http://stormy-window-812.heroku.com/ | git@heroku.com:stormy-window-812.git Michael$ git push heroku master ! Invalid path. ! Syntax is: git@heroku.com:.git where is your app's name fatal: The remote end hung up unexpectedly
我不确定是什么问题.我做一个普通的heroku创建,我的git正在为github加载代码.有什么我想念的吗?路径似乎是正确的格式,所以我不知道问题是什么.