# Call methods within a given block

**URL:** <https://discuss.rubyonrails.org/t/call-methods-within-a-given-block/3316>\
**Category:** rubyonrails-talk\
**Created:** [October 19, 2006, 2:20pm UTC](https://discuss.rubyonrails.org/t/call-methods-within-a-given-block/3316 "2006-10-19T14:20:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Roelofs](https://avatars.discourse-cdn.com/v4/letter/j/e274bd/32.png) [@Jason\_Roelofs](https://discuss.rubyonrails.org/u/Jason_Roelofs)\
**Post date:** [October 19, 2006, 2:20pm UTC](https://discuss.rubyonrails.org/t/call-methods-within-a-given-block/3316/1 "2006-10-19T14:20:06Z")

</div>

Rendering in Rails is ‘magic’, in that it’s not actually getting run in the context of your controller. The renderer takes your controller’s instance methods ( @varname ) and makes them available to the template. Any methods you try to call will be looked for in the Controller’s Helper module. Seeing as you’re using #render in an action, you’re better off calling and saving the data before the #render call:

@filter = filter render(:update) { |page| page.replace\_html ‘filterkriterien’, :partial =\> ‘partials/filter’, :locals =\> { :filter =\> @filter } }

Jason

---

<div class="post-metadata">

**Author:** ![Erik1](https://avatars.discourse-cdn.com/v4/letter/e/8e8cbc/32.png) [@Erik1](https://discuss.rubyonrails.org/u/Erik1)\
**Post date:** [October 20, 2006, 6:24pm UTC](https://discuss.rubyonrails.org/t/call-methods-within-a-given-block/3316/2 "2006-10-20T18:24:36Z")

</div>

You can designate controller methods be available to the views by using 'helper\_method' in the controller. Like so:

def whatever\_controller\_method &nbsp;&nbsp;# whatever end helper\_method :whatever\_controller\_method
