Split callbacks for easier overwriting

This commit is contained in:
David Heinemeier Hansson
2025-11-03 16:00:35 +01:00
parent 6678d0e4fc
commit fcad4518da
2 changed files with 8 additions and 7 deletions
+5 -3
View File
@@ -2,14 +2,16 @@ class Public::BaseController < ApplicationController
allow_unauthenticated_access
allow_unauthorized_access
before_action :set_collection_and_card
before_action :set_public_cache_expiration
before_action :set_collection, :set_card, :set_public_cache_expiration
layout "public"
private
def set_collection_and_card
def set_collection
@collection = Collection.find_by_published_key(params[:collection_id] || params[:id])
end
def set_card
@card = @collection.cards.find(params[:id]) if params[:collection_id] && params[:id]
end
@@ -1,14 +1,13 @@
class Public::Collections::ColumnsController < Public::BaseController
before_action :set_column, only: :show
before_action :set_column
def show
set_page_and_extract_portion_from @column.cards.active.latest.with_golden_first
end
private
# Unlike the other public controllers, this is using params[:id] to fetch the column
def set_collection_and_card
@collection = Collection.find_by_published_key(params[:collection_id])
# Unlike the other public controllers, this is using params[:id] to fetch the column instead of the card
def set_card
end
def set_column