# Calling content\_for from a controller

**URL:** <https://www.ruby-forum.com/t/calling-content-for-from-a-controller/171762>\
**Category:** Rails\
**Created:** [July 8, 2009, 8:11pm UTC](https://www.ruby-forum.com/t/calling-content-for-from-a-controller/171762 "2009-07-08T20:11:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjkiesch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc79bd/32.png) [@jjkiesch](https://www.ruby-forum.com/u/jjkiesch)\
**Post date:** [July 8, 2009, 8:11pm UTC](https://www.ruby-forum.com/t/calling-content-for-from-a-controller/171762/1 "2009-07-08T20:11:24Z")

</div>

i’ve got a helper method that calls content\_for to get all of the  
content for a sidebar. it’s kind of annoying though because i’m having  
to go into each template file and add \<% render\_sidebar %\>

it’d be great if i could add some before filter in the controller and  
specify what actions i want the helper method to be called but my  
controller doesn’t like me calling content\_for inside of it. what’s  
the best way of doing something like this to avoid the repetition of  
having to add duplicate code to all of my templates?
