docbrown/app/controllers/collections_controller.rb
Christopher Wray 9e439fcf6e
Fix Bug: Series index page showing series with 0 articles -#9658 (#11227)
* added join to index collections controller

* + collections test to not show empty series
2020-11-03 09:10:46 +01:00

12 lines
420 B
Ruby

class CollectionsController < ApplicationController
def index
@user = User.find_by!(username: params[:username])
@collections = @user.collections.joins(:articles).distinct.order(created_at: :desc)
end
def show
@collection = Collection.find(params[:id])
@user = @collection.user
@articles = @collection.articles.published.order(Arel.sql("COALESCE(crossposted_at, published_at) ASC"))
end
end