Displaying 20 results from an estimated 6000 matches similar to: "Rendering all the elements when calling Array#to_xml"
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
2008 May 08
2
Testing render :text without has_text
A controller I''m trying to test simply delivers a text string to the
client, which then demarshalls it to retrieve some objects. I want to
test that the returned string is correct.
I don''t want to compare the string character-by-character with
response.has_text because that ties me to the implementation of the
Marshall class. Instead, I just want to demarshall the string
2007 Mar 28
7
Rails, REST and JSON
Hi everyone,
I''m writing a lightweight AJAX application using Rails on the server side as
a RESTful web service provider.
I need the web service to support both JSON and XML I/O. Outputting data in
XML and JSON is easy (using to_xml and to_json),
and it''s also easy to do XML input as Rails does it for you automatically.
Is it possible to somehow have the same
automatic parsing
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
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
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 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 =>
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
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 Jun 19
6
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 ?
if it not possible, what are the "rails
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,
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
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
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/.
2012 Feb 07
2
save method (create action) saves twice
Rails 3.1.3
I have changed a regular scaffold action a bit so that it can save using
ajax.
All I needed to do was adding ":remote => true" in
<div id="script_new">
<%= form_for script, :remote => true do |f| %> <!-- HERE!!! -->
<%= f.hidden_field :video_id %>
<%= f.text_field :text %>
<%= f.submit "save" %>
2008 May 21
6
this.initialize has no properties error in Prototype Code
Hi All,
I''m a super newbie with Prototype and am trying to implement my first
solution using it.
This is my code:
var span = ''totalViews'' + video_id;
var params = ''video_id='' + video_id;
Ajax.Response(''trackVideo.php'',
{
method: ''post'',
parameters: params,
onSuccess: function(transport)
{
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
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?
2006 Jun 09
2
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 Timezones". Come to think of it I bet