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| %> <div class="row"> <%= link_to user_posts_url(user.id) do %> <div><%= user.name %></div> <% end %> </div> <% 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)