# Render :update and local variables

**URL:** <https://www.ruby-forum.com/t/render-update-and-local-variables/122241>\
**Category:** Rails\
**Created:** [December 5, 2007, 9:08pm UTC](https://www.ruby-forum.com/t/render-update-and-local-variables/122241 "2007-12-05T21:08:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin\_cline](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/3d9bf3/32.png) [@kevin\_cline](https://www.ruby-forum.com/u/kevin_cline)\
**Post date:** [December 5, 2007, 9:08pm UTC](https://www.ruby-forum.com/t/render-update-and-local-variables/122241/1 "2007-12-05T21:08:58Z")

</div>

Probably asked and answered, but…

Why are controller instance variables visible in the block passed to  
render :update, but controller private methods are not?

This does not work:

class MyController \< ApplicationController  
def some\_action  
render :update do |page|  
page.replace\_html ‘element’, some\_data # some\_data is not  
defined  
end  
end

private  
def some\_data  
…  
end  
end

---

<div class="post-metadata">

**Author:** ![kevin\_cline](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/3d9bf3/32.png) [@kevin\_cline](https://www.ruby-forum.com/u/kevin_cline)\
**Post date:** [December 5, 2007, 9:14pm UTC](https://www.ruby-forum.com/t/render-update-and-local-variables/122241/2 "2007-12-05T21:14:16Z")

</div>

On Dec 5, 8:08 pm, kevin cline [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Probably asked and answered, but…
> 
> Why are controller instance variables visible in the block passed to  
> render :update, but controller private methods are not?

Because at the end of the day it’s the same as rendering any old  
template: instances variables are copied across into a magic object,  
which is not the controller (and so controller private methods are not  
available)

Fred
