search for: to_xml

Displaying 20 results from an estimated 106 matches for "to_xml".

2007 Feb 21
Rendering all the elements when calling Array#to_xml
When I call to_xml on an array, I want it to get the XML for all the elements in it. I''ve defined to_xml in my class. >> r.to_xml => "<video><id>1</id><views>2</views></video>" >> a = [r] => [#<StatisticsReport:0x3259f38 @video_...
2006 Jun 19
to_xml depth ...
hello, The "render :xml => myFriends.to_xml", return something like: <people> <person> <id type="integer">2</id> ... <person> But a Person has a "has_many" relationship and they are not in the xml, => so is it possible to change the depth of the marshall process...
2006 Aug 15
to_xml and underscores
hi, i am looking for a solution whereupon calling myEntityObject.to_xml does not convert my attributes containing underscores into hyphens. at the moment an attribute named "my_own_attribute" is converted into <my-own-attribute>. does anybody have an idea how to change that and have to_xml generate <my_own_attribute> thanks ciao robertj -- P...
2009 Jan 05
ROXML versus simple to_xml
How they differ? Does the to_xml method of the classes array/hash/object is based on ROXML lib? As I see in, roxml needs we define the class (class Book in the guide) before to convert a object to xml. Moreover, the method to_xml (when not using "include ROXML")...
2010 Feb 11
Inconsistent Hash#to_xml Method
I have a unit test that demonstrates some inconsistent behavior with a Hash being converted to XML with the :root option. Sometimes it works fine: => ''test'') "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test>\n</test>\n" But sometimes I get an argument error: => ''test'') ArgumentError Exception: wrong number of arguments...
2008 Aug 28
Rendering User attributes in XML
Let''s say an app has a User, and a User has many friends. Also, let''s say the app authentication was built on the restful_authentication plugin, and we have email and password in the Users table. The friends controller index might look like this; # GET /users/1/friends # GET /users/1/friends.xml def index @users = @user.friends respond_to do |format|
2009 Jul 31
Would like include model association in to_xml
i have: class Library << ActiveRecord::Base has_many :books end class Book << ActiveRecord::Base belongs_to :library end in my controller i have: render :xml=> Library.find(:all).to_xml(:include=>books) but, i would like put a condition in the books ( e.: pages >= 100 ) i would like to create a xml with all Libraries, but books with pages more than 100) How to do this? -- Ítalo Matos Cavalcante Santos Desenvolvedor Web/Mobile Analista de Sistemas http://ita...
2009 Jan 21
AR to_xml problem with associations, Builder::XmlMarkup#to_a
When I do a to_xml(with a block) on an association of a model I got a Builder::XmlMarkup#to_ary should return Array Example that does not work. @intervenant = Intervenant.find(params[:id]) output = @intervenant.to_xml( :skip_types => false, :dasherize => false) do |xml| @intervenant.individu.t...
2006 Jul 14
creating a computed column with activerecord for to_xml
Hi. I have a question about activerecord, computed columns and to_xml. I have a simple model called person that has a first_name and a last_name field (and thus a first_name and last_name field in the Person table). When I :find a model and call to_xml, I would like the result to not only send back first name and last name as xml but also add an additional attr...
2010 Mar 08
to_xml repeating elements and plain strings
Say I want to output XML like this: <myXML> <id>123</id> <fruit>apple</fruit> <fruit>banana</fruit> <fruit>pear</fruit> <fruit>lemon</fruit> </myXML> Is there a way of doing that with to_xml? It seems like there''s two problems: to_xml always creates a wrapping element <fruits> when it encounters an array, and... You can put plain strings into hash values and it works, but plain strings in arrays doesn''t work. That''s this guy''s problem again h...
2006 Jul 31
is it possible to make to_xml use underscore instead of dash?
Hi all, I am getting ActiveRecord to produce XML with render :xml => @user.to_xml However, on the client end it is a bit annoying for me to deal with attributes like first-name. I would much rather have first_name. Is there any way for me to turn off the behavior of converting _ to -? This seems to be done by a call to dasherize inside the to_xml of ActiveSupport::CoreExtens...
2008 May 23
Problem with .to_xml and Hash.form_xml ?
Hi, i m trying to do some kind of database dump using .to_xml and after i try to fill my database back (well an other) with the content of the xml. Right now i m doing that : @xml = Video.find(:all).to_xml(:include=>[:vlogiciels]) it does produce : <videos> <video> <mycolumns> ..... <vlogiciels>...
2007 Jan 17
changing the default behaviour of to_xml for has-many: associations
I recently submitted a patch to work around an issue I was having & added a new optional behaviour to the to_xml method but on further reflection I wonder if the default behaviour should be changed. The gory detail, documentation and test case is all here... Here''s a brief example... class Person < ActiveRecord::Base has_many: children...
2006 Jul 31
to_xml using lots of memory
to_xml uses up huge amounts of memory. Whether I use to_xml on an activerecord object directly, or create a hash from the activerecord object and then call to_xml on the hash, creating a 1.6mb xml file eats up 50mb of ram in rails.
2007 Nov 20
Anyone using to_xml and procs...
I''m looking for comments on In my opinion, the current behaviour is a bug, and should be fixed. If you have a use case where passing procs to the child associations is actually useful, chime in. Jonathan del Strother --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the
2008 Apr 22
Overriding to_xml() - Why Does This Work?
In Chapter 5 of his book, Flexible Rails, Peter Armstrong''s leads his readers through an exercise to override the behavior of to_xml() in ActiveRecord objects so that :dasherize would be false by default. I found his solution inelegant. I came up with a more elegant one, and it seems to work. All I did was add the following to the very end of myapp/config/ environment.rb: class ActiveRecord::Base def to_xml(options...
2010 Feb 20
Advanced use of to_xml and to_json
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...
2007 May 17
Namespaced model valid #to_xml support in ActiveRecord, ActiveSupport and ActiveResource creating a new Trac ticket for ARes, which will be affected if both of these patches are accepted by Core. There are a couple of workarounds for this issue, but it would be nice for AR, AS and ARes to output valid XML and resolve to namespaced models correctly from XML respectively. Currently #to_xml on ActiveRecord::Base and Array creates invalid XML output for namespaced models. For one of the workarounds (which unfortunately seems to break RSpec partial mocks of models) see one of my blog postings at:
2006 Jun 09
Timzones, UTC, and to_xml()
Does anyone know a good way to hook into the AR to_xml() method to allow for adjusting datetimes to a user''s timezone? Basically I want a user to be able dump all their data before cancelling an account. I store all datetime info as UTC as per the recommendations of Jamis Buck and Scott Barron in the Rails Recipe article "Dealing with T...
2010 Feb 19
Problem in ActiveRecord#to_xml
Hi, a couple of days ago I filed a ticket related to a problem with the to_xml ActiveRecord method. ( ). I solved it by making to_xml to infere the type by means of a ruby-xml type...