I need to supply data from my Ruby on Rails database to a jquery grid plugin. At the moment, I’m doing it like this:
@notes = current_user.notes.all
respond_to do |format|
format.xml { render :xml => @notes }
end
But I only want to display certain fields in the grid, so I need to change the code to only send specified fields from the model. What is the easiest way to do this? Thanks for reading.
you can use XML Builder.
Taken from: http://danengle.us/2009/05/generating-custom-xml-for-your-rails-app/
Another possibility is to override to_xml in your notes model as posted in the comments of the linked site above.