I have a resource of Player
that has various nested resources, such as: Measurable
and Workout
.
I have a variable that is used int he Player's header on their pages and it has a variable I need to be set whether I'm accessing an action from the Player_Controller or from one of the other nested resources controllers. How can I dry up my code to add that variable somewhere so that I don't have to include the same like of code in every controller... as shown below:
PlayerController
class PlayersController < ApplicationController
before_action :set_measurable_summary
#...
private
def set_measurable_summary
@measurable_summary = @player.measurable_summary
end
end
WorkoutController
class Players::WorkoutsController < ApplicationController
before_action :set_measurable_summary
#...
private
def set_measurable_summary
@measurable_summary = @player.measurable_summary
end
end