Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instance variable visibility on callback method #1

Open
knightq opened this issue May 4, 2012 · 0 comments
Open

Instance variable visibility on callback method #1

knightq opened this issue May 4, 2012 · 0 comments

Comments

@knightq
Copy link

knightq commented May 4, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant