KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have an ActiveRecord model that I would like to convert to xml, but I do not want all the properties rendered in xml. Is there a parameter I can pass into the render method to keep a property from being rendered in xml? Below is an example of what I am talking about. def show @person = Person.find(params[:id]) respond_to do |format| format.xml { render :xml => @person } end end produces the following xml <person> <name>Paul</name> <age>25</age> <phone>555.555.5555</phone> </person> However, I do not want the phone property to be shown. Is there some parameter in the render method that excludes properties from being rendered in xml? Kind of like the following example def show @person = Person.find(params[:id]) respond_to do |format| format.xml { render :xml => @person, :exclude_attribute => :phone } end end which would render the following xml <person> <name>Paul</name> <age>25</age> </person>
Tags (comma-separated)
Save Edits
Cancel