class WordCloudsController < ApplicationController
  before_action :set_section
  before_action :authorize_word_cloud

  def show
    gon.words = @section.word_cloud
  end

  private

  def set_section
    @section = MasterSection.find(params[:id])
  end

  def authorize_word_cloud
    project = @section.project

    return if can?(:read, project)

    redirect_to root_path, alert: "You are not authorized to access this page."
  end
end
