Displaying 20 results from an estimated 10000 matches similar to: "ROXML versus simple to_xml"
2009 Feb 03
3
ROXML from_xml not returning an object instance...
Hello,
I have two ActiveRecord classes. One is Route the other is Waypoints.
I have constructed an XML representation so I can use AJAX to create a
Route with all waypoints in a single create call to RouteController.
When I call Route.from_xml(xmlString) it is not returning an object -
it''s leaving the object (@route) nil, but not erroring. Any ideas?
Here''s some code:
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?
2011 Mar 26
2
How to deserialize an array from XML
Hi,
to serialize an array to xml we can use:
an_array = [ 1, 2, 3]
an_array.to_xml
But to I can''t find a way to convert back XML to array. I didn''t find a
method Array.from_xml like Hash.from_xml.
Any ideas?
Thanks,
Gustavo
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email
2008 Oct 14
6
Disabling XML character escaping for to_xml
Currently, it appears to_xml will automatically escape any entities
into their corresponding &XXX representation. There''s a piece in the
documentation that says "If $KCODE is set to u and encoding set to
UTF8, then escaping will NOT be performed."
Unfortunately, this doesn''t appear to be the case. Even after
following the docs and ensuring that default_charset is
2010 Apr 05
2
Harmonizing JSON/XML serialization
The way Rails handles root nodes in JSON and XML serialization is
inconsistent. This has been discussed before:
https://rails.lighthouseapp.com/projects/8994/tickets/2584-232-activeresource-json-doesnt-send-parameters-with-root-node
This seems mostly taken care of with
ActiveModel::Base.include_root_in_json, especially if/when it ends up
in ActiveResource. However, there is also the issue of how
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\"
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
2008 Aug 28
12
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|
format.html
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 =>
2008 Oct 08
11
Using image_tag and send_data
I am using image_tag to load an image that I''ve saved to the database
(using attachment_fu if you''re curious but that''s probably not
relevant here):
VIEW
<%= image_tag ''/photo/get_image/5'' %>
CONTROLLER
def get_image
@photo=Photo.find(params[:id])
send_data(DbFile.find(@photo.db_file_id).data,
:type =>
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 Mar 25
11
ActiveRecord: Nested :include erroneous behavior
Hi,
Found a simple example breaking on moving to 2.2 from 2.0. This
example illustrates the usage of nested :include finder options.
class Book < ActiveRecord::Base
has_many :distributors
end
class Distributor < ActiveRecord::Base
belongs_to :book
has_many :agents
end
class Agent < ActiveRecord::Base
belongs_to :distributor
has_many :shops
end
class Shop <
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 Nov 30
12
How to go back to using webrick default server
Hi,
I''ve installed mongrel to check it out and want to go back to using
webrick as default when i type server/script to run my server. How can I
do this? I know that I can just type server/script webrick but i''d
prefer to have it as default.
Thanks
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because
2008 Aug 24
11
link_to_function check javascript attribute
How could I check the value of an javascript object''s attribute?
<div id="new_item_details" style="display:none"></div>
<%= link_to_function("Show details...", nil, :id => "show_details") do
|page|
page.visual_effect(:toggle_blind, :new_item_details)
if (page[:new_item_details].style.visibility ==
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>
2008 Oct 08
9
Plugins and the test environment
Hi guys. I''m writing a plugin for use in the test environment.
However, when I run ``rake test'''' or ``rake spec'''', RAILS_ENV is set
to "development" when my plugin''s init.rb is run.
How do you configure a plugin to load require a file in the test
environment?
Thanks,
Nick
--~--~---------~--~----~------------~-------~--~----~
You