docbrown/app/controllers/collections_controller.rb
Alberto Pérez de Rada Fiol 115adbb1bd
[deploy] Add index and show pages for series (#9201)
* Add index and show pages for series

* Address code review

* Use `id` instead of `slug` to get collections

* Extract `collection_link` into the application helper

* Only count published articles

* Get rid of the `collection_link_class` method

* Add tests

* Fix test

* Use `**kwargs` instead of `options = {}`
2020-07-29 10:01:52 -04:00

12 lines
394 B
Ruby

class CollectionsController < ApplicationController
def index
@user = User.find_by!(username: params[:username])
@collections = @user.collections.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