similar to: to_xml using lots of memory

Displaying 20 results from an estimated 100000 matches similar to: "to_xml using lots of memory"

2010 Feb 19
0
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. ( https://rails.lighthouseapp.com/projects/8994/tickets/3982-patch-solved-a-bug-that-prevented-xml-serialization-when-activerecord-attributes-contains-more-than-column-values ). I solved it by making to_xml to infere the type by means of a ruby-xml type conversion, using a Hash that was already
2006 Jul 31
2
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
2006 Jul 14
1
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 attribute called full_name that is
2009 Jan 09
2
Confused about to_xml() in ActiveRecord::Base subclass
Since all my efforts to control how to_xml() is formatting dates has failed, I''m now considering writing my own to_xml(). However, from the limited examples I''ve found, I just don''t understand how to actually reference the columns for the records in my record set. Here''s a simplified view of my ActiveRecord object: class Errors < ActiveRecord::Base
2009 Jan 21
3
Nested serialization with to_json and to_xml with array and hash element
Title: Nested serialization with to_json and to_xml with array and hash element class Person < ActiveRecord::Base has_one :address has_one :job def office() return "Executive_Suite" end end class Address < ActiveRecord::Base belongs_to :person end class Job < ActiveRecord::Base belongs_to :person has_one :paygrade def Title return "Engineer" end end
2008 Apr 22
0
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
2007 Jan 02
0
to_xml eager loading?
Activerecord supports eager loading with the following syntax: Author.find(:all, :include=>[{:posts=>:comments}, :categorizations]. to_xml has an :include option that supports a shallow form of eager loading to create the xml: author.to_xml(:include[:posts]). Is there a way to generate the xml from all associated objects for a particular model instance?
2007 Jan 17
4
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... http://dev.rubyonrails.org/ticket/7004 Here''s a brief example... class Person < ActiveRecord::Base has_many: children
2009 Jan 05
5
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 http://roxml.rubyforge.org/#quickstart, 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") just accepts any existing object, what is much suitable. I need to compare and tranfer
2010 Mar 08
1
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
2007 May 17
4
Namespaced model valid #to_xml support in ActiveRecord, ActiveSupport and ActiveResource
Hi, Attached are links to two patches I submitted via the RoR Trac system a week or so ago: http://dev.rubyonrails.org/ticket/8305 http://dev.rubyonrails.org/ticket/8308 I refrained from 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
2010 Feb 11
2
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: Hash.new.to_xml(:root => ''test'') "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<test>\n</test>\n" But sometimes I get an argument error: Hash.new.to_xml(:root =>
2006 Dec 03
0
How to best change the default value of dasherize (using Edge Rails, and knowing about :dasherize => false)?
Hi all, I''m trying to turn off dasherize in all cases, since converting underscores to hyphens breaks the way that I want to handle XML (with E4X in Flex 2). I''ve read the other threads about dasherize on this list. I''m on Edge Rails, so I can successfully turn off dasherize for a single usage with something like render :xml => @task.to_xml(:dasherize => false)
2007 Feb 21
1
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_id=1, @views=2>] >> a.to_xml => "<?xml version=\"1.0\"
2008 May 24
1
to_xml for Foo::Bar active records
20 / 20 hind sight, I would probably do things different today but I have most of my active record classes under different parent classes. For example: module Foo class Bar < ActiveRecord::Base ... end end The to_xml for this produces <foo/bar> .... </foo/bar> The / in a tag name is not allowed. Questions: 1) Is this a bug? 2) If so, suggestion of what to convert it to?
2008 May 23
3
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> <logiciel>
2009 Jan 21
1
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.to_xml( :builder => xml, :skip_instruct => true, :skip_types => false,
2007 Dec 12
2
to_xml ignore fields
Hi! I''d like to know how to (most easily) ignore some elements from produced XML .. for example: @people.to_xml produces: <person> <id>2</id> <name>bob</name> <street>carson street</street> </person> ... How can I *not* produce the "ID" field for example? Thank you! -- Posted via http://www.ruby-forum.com/.
2009 Jul 31
8
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
2007 Feb 15
3
Restrict attributes in to_xml
For example, let''s say I have a User model with 2 attributes: 1. pw_hash 2. pw_salt I don''t want these to show up in the to_xml method. How do I keep to_xml from using these attributes? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: