In an app with pages that can be loaded normally or from ajax (`jQuery.load()`), how do I setup rails formats properly? Right now I'm using the following code in every action:

```
def show
  respond_to do |format|
    format.html { render layout: !request.xhr? }
  end
end

```

Is there a way to make this global, and not to have to write it in every action?

**Edit**:

I tried putting it in an `after_filter` as suggested in the comments, but that gave me an error that `Render and/or redirect were called multiple times in this action.`