class Characters::TitlesController < ApplicationController before_action :set_character def index @title_awards = @character.title_awards end def activate @title = Title.find(params[:title_id]) if current_char.title_awards.exists?(title: @title) current_char.update(active_title: @title) else flash[:alert] = "You haven't earned that title." end redirect_to character_titles_path(current_char) end private def set_character @character = Character.find(params[:character_id]) unless current_char == @character flash[:alert] = "You can only look at your own titles." redirect_to character_path(@character) end end end