<p>I have the following <code>before_filter</code>:</p>

<pre><code>  def find_current_membership
    respond_to do |wants|
      wants.html { @current_membership = @group.memberships.for(@current_user) }
      wants.rss  {}
      wants.js   { @current_membership = @group.memberships.for(@current_user) }
    end
  end
</code></pre>

<p>I would like to share the code for the HTML and JS blocks.  Is there a better way than just throwing the code into a method?  I was hoping this would work:</p>

<pre><code>  def find_current_membership
    respond_to do |wants|
      wants.rss  {}
      wants.all  { @current_membership = @group.memberships.for(@current_user) }
    end
  end
</code></pre>

<p>But alas, it did not.</p>

In this case you could probably do something like:
```
```
before_filter :only => :find_current_membership do |c|
    load_current_membership if not request.format.rss?
end
```
```
Alternatively you could use the request.format.rss? in your controller method to conditionally load the memberships.
Either way your first step should be to refactor that into a method.