title: Removing duplicated code within two 'render :update do |page|' blocks
body: <p>In a rails controller I have two updates that have similar 'render :update do |page|' blocks. The two blocks are not exactly the same, so I'd like to extract the duplicated code like this:</p>
  
  <pre><code>def render_1
   render :update do |page|
    shared_update_code(page)
    page.replace('render_1_specific_id', :partial =&gt; 'foo')
   end
  end
  
  def render_2
   render :update do |page|
    shared_update_code(page)
    page.replace('render_2_specific_id', :partial =&gt; 'bar')
   end
  end
  
  private
  
  def shared_update_code(page)
    page.replace('common_id', :partial =&gt; 'foobar')
  end
  </code></pre>
  
  <p>But this approach doesn't work. Within the render :update block, calls to other controller methods fail since I'm now in an ActionView context. </p>
  
  <p>Any ideas on how I can DRY up this code?</p>