similar to: AR to_xml problem with associations, Builder::XmlMarkup#to_a

Displaying 20 results from an estimated 600 matches similar to: "AR to_xml problem with associations, Builder::XmlMarkup#to_a"

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
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 Apr 28
0
Writing an imgae tag in to_xml
Hi, I am trying to create an pdf report by using ruby jasper pages. For that I have written customer_list.rxml file like this: xml.instruct! xml.customer_list_result do xml.invoice_customers do @customers.each do |customer| xml << customer.to_xml(:dasherize=>false,:skip_instruct=>true,:only=>[:id,:name,:city],:root=>"customer") end end end I want to
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 Jun 11
2
Builder::XmlMarkup and dashes
Has anyone hacked Builder::XmlMarkup to dasherize underscore tags by default? I know I can use tag!, but I''d like to find a way for it to translate underscores to dashes automatically. In other words: xml.department_manager do "fred end #=> <department-manager>fred</department-manager> I tried hacking Builder::XmlBase.method_missing but got myself all twisted up!
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)
2010 Aug 29
0
active_support/mini_xml question/bug?
I''ve hit a problem which no one on the regular rails list seems to know about. I''ve studied the rails code but I can''t get to the bottom of it, so I thought I''d ask here. It''s about active_support/mini_xml: Seems to me that {}.to_xml is generating one level too many of xml structure, but I may be interpreting things incorrectly... I''ve reduced
2006 Aug 15
2
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 -- Posted via
2010 Aug 22
7
Rails 3: Error saving an object with no useful information
Hey, I''m kinda desperate cause I''m getting an error and have no idea how to fix this since it doesn''t give me any information hinting where the problem is: irb(main):054:0> reload!;User.last.save! Reloading... NameError: undefined local variable or method `to_ary'' for #<User:0x4ed5d20> from
2010 Feb 20
1
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
2006 Jun 20
3
How to get hold of a patch
I have been researching a problem and found that ticket 4989 solves my problem (to_xml has new dasherize option). I am new to RoR and was wondering if the patch that has been mentioned is available for public release. If so where can I find it and how to apply? Thank you Andrew -- Posted via http://www.ruby-forum.com/.
2008 Nov 10
3
to_xml and helper methods
Hi, I have an array with objects and I want to generate an XML like: <objects> <object> <category_id>1</category_id> <helper-method>result 1</helper-method> </object> <object> <category_id>2</category_id> <helper-method>result 2</helper-method> </object> </objects> The helper
2008 Jan 08
1
howto rebuild a object from a received xml hash structure ?
im my web server app , i have an action to be used as a REST web service # GET /user/membership.xml?email=emailaddress def membership @user = User.find_by_email(params[:email]) respond_to do |format| format.xml { render :xml => @user.to_xml( :only => [ :first_name, :last_name, :display_name, :membership_type, :membership_at], :skip_types => true)} end end my
2007 Sep 30
1
to_xml node names with underscores
When I call to_xml on my active record objects, it replaces underscores with hypens. E.g.: <categories> <category> <content-provider-id type="integer">1</content-provider-id> <id type="integer">2</id> <name>Traffic Alerts</name> </category> </categories> When the actual field is content_provider_id. I remember
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\"
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
2006 Jul 31
0
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 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:
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
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 =>