In xml responses, if the result is an empty array we want the response to look like this: <posts type="array"/> not like this (the default): <nil-classes type="array"/> This refactors controllers so that this is done automatically instead of having to manually call `@things.to_xml(root: "things")` everywhere. We do this by overriding the behavior of `respond_with` in `ApplicationResponder` to set the `root` option by default in xml responses.
10 lines
308 B
Ruby
10 lines
308 B
Ruby
class ArtistVersionsController < ApplicationController
|
|
respond_to :html, :xml, :json
|
|
|
|
def index
|
|
@artist_versions = ArtistVersion.includes(:updater).search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
|
respond_with(@artist_versions)
|
|
end
|
|
|
|
end
|