خرید بک لینک

Vote count: 0

There is no problem with sqlite 3 but 'PG :: GroupingError: ERROR' appears in posgresql's environment.

I want to display posts with a lot of total by using paginate's gem in the order of total of like, but it is displayed without problem in sqlite 3

posts_controller.rb

  def popular
    @posts = Post.joins(:likes).group(:post_id).order("count(*) desc").paginate(:page => params[:page], :per_page => 18)
  end

However, in the postgres environment, 'PG :: GroupingError: ERROR: column' posts.id 'must appear in the GROUP BY clause or be used in an aggregate function' will be displayed and an error will be displayed.

It will be very helpful to tell me

thank you

asked 57 secs ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 13 ارديبهشت 1396 ساعت: 7:58

صفحه بندی