title: is it possible to use a variable value across multiple actions
body: <p>I have index and show method like below</p>
  
  <pre><code>def index
    @variable = SomeModel.includes(:some_other_model)
  end
  
  def show
    @variable = SomeModel.includes(:some_other_model).find_by!(id: params[:id])
  end
  </code></pre>
  
  <p>so <code>SomeModel.includes(:some_other_model)</code> is common in both actions and i am doing join on some_other_model twice in index and show method</p>
  
  <p>so i thought lets do before_action move it to a private method</p>
  
  <pre><code>  before_action :set_something, only: [:index, :update]
  
      def index
        @variable
      end
  
      def show
        @variable.find_by!(id: params[:id])
      end
  
        private
  
      def set_something
      @variable = SomeModel.includes(:some_other_model) if @variable.nil?
    rescue ArgumentError =&gt; e
      render_error(:bad_request, e.message)
    end
  </code></pre>
  
  <p>So my question is, is there any way i can store the @variable value when either index or show is called and when next time other action is called just use the same @variable value and not hit database again?</p>