docbrown/app/controllers/sidebars_controller.rb
Jeremy Friesen 973ff20eb8
Refactoring to consolidate logic (#15851)
* Refactoring to consolidate logic

Prior to this commit, two controllers had nearly identical chunks of
logic.  This refactor extracts the logic to a common and more canonical
location.

* Addressing rubocop's aggressive auto-fix

* Adding spat operator for pluck

* Renaming method for greater clarity
2021-12-29 11:08:04 -05:00

16 lines
405 B
Ruby

class SidebarsController < ApplicationController
layout false
before_action :set_cache_control_headers, only: %i[show]
def show
get_latest_campaign_articles
set_surrogate_key_header "home-sidebar"
end
private
def get_latest_campaign_articles
@campaign_articles_count = Campaign.current.count
@latest_campaign_articles = Campaign.current.plucked_article_attributes
end
end