How to sort joined tables?

help please write orm-request.

tables:
users:
id: integer
name: varchar

posts:
id: integer
title: varchar
user_id: integer
views: integer

models:
User:
class User < ActiveRecord::Base
has_many :posts, dependent: :destroy
end

Posts:
class Post < ActiveRecord::Base
belongs_to :user
end

controller:
def popular_diary
@users =
User.joins(:posts).group_by(:user_id).order(‘SUM(posts.views)’)
end

html:
<% @users.each do |user| %>


<%= link_to user_posts_url(user.id) do %>
<%= user.name %>

<% end %>

<% end %>

I need that all users hatched in a certain order. order ('SUM
(posts.views)

The problem is that the screen displays the following error message:
wrong number of arguments (0 for 1)

Look near the error message it will show you what line the error
occurred
at.

On Thu, Jun 25, 2015 at 5:56 AM, Zlodiak Z. [email protected]

tamouse m. wrote in post #1175655:

Look near the error message it will show you what line the error
occurred
at.

On Thu, Jun 25, 2015 at 5:56 AM, Zlodiak Z. [email protected]

http://joxi.ru/1A5RvGah55YwrE

sorry. i replace ‘group_by’ on ‘group’ and it worked)