Hello, I''m working on a Rails app which has a REST API. I manage two formats JSON and XML. Very often to simplify the use if the API, I''m making includes. But when you add params to to_json and to_xml like :only, :except, it''s not only applied on the root object but on all the objects included. Do you know libs or methods to answer to these different problems: * Tell never return a user password in the API * Tell always include a relationship or a method in each user serialized in the API * Serialize objects depending on context. For exemple, when a user ask for the user list, he should see its complete profile, a partial profile of its friends and just the name of others... * Don''t have to copy paste the parameters for xml and json Thank you very much, Camille Roux -- Posted via ruby-forum.com. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
Hi Camille, On Sat, 2010-02-20 at 17:15 +0100, Camille Roux wrote:> Hello, > > I''m working on a Rails app which has a REST API. I manage two formats > JSON and XML. > Very often to simplify the use if the API, I''m making includes. But when > you add params to to_json and to_xml like :only, :except, it''s not only > applied on the root object but on all the objects included.I use Builder when the to_xml method is not flexible enough. api.rubyonrails.org/classes/Builder/XmlMarkup.html For json, there is no current equivalent AFAIK, but googling ''rails builder json'' gave some trails to follow. HTH, Bill -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at groups.google.com/group/rubyonrails-talk?hl=en.
Seemingly Similar Threads
- Nested serialization with to_json and to_xml with array and hash element
- is it possible to make to_xml use underscore instead of dash?
- Confused about to_xml() in ActiveRecord::Base subclass
- AR to_xml problem with associations, Builder::XmlMarkup#to_a
- Harmonizing JSON/XML serialization