Skip to content

Instance variable visibility on callback method #1

@knightq

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.

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