Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

Instance variable visibility on callback method #1

Description

@knightq

In my use case I need to factor rendering logic whose behaviour is conditioned by some values computed on the action:

class StatisticsController < ApplicationController
  before_render :choose_render
  def my_custom_action
    ...
    @records = <something>
    .,.
  end
  ...
  def choose_render
     if @records.first # here is an exception (@records is nil)...
     ...
  end
end

but it is not possible, since @records is not available in the context of the callback function choose_render.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions