Displaying 20 results from an estimated 7000 matches similar to: "Problem in ActiveRecord#to_xml"
2010 Nov 01
1
[patch] Allowing to_xml to rename keys in lower camel case format
Hi all,
I''ve created and submitted a patch to resolve an issue I had while
attempting to meet the OpenSocial API specifications, which dictates that
the xml output have tags formatted as lower camelcase (as opposed to upper
camelcase, which is currently the only option). With this patch, simply
passing :camelize => true still begets the current behavior, but you can now
enable lower
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
2010 Apr 09
0
[PATCH] add :root option to ActiveModel JSON serialization
This is a small, straightforward patch that I''d love to see merged:
https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/4358-patch-add-root-option-to-activemodel-json-serialization
It''s all pretty self-explanatory, it basically just ports a useful
option from to_xml to to_json, making their interfaces more compatible
with each other. Feedback would be greatly
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
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 May 01
0
Add custom root option to AR JSON Serializer
Hi,
In short: I can do following:
user.to_xml(:root => "xml_user" )
But not following:
user.to_json(:root => "json_user")
JSON serializer for AR doesn''t allow us to specify "root" option unlike XML
serializer. JSON serializer always uses model name as the root if class
attribute include_root_in_json is set to true.
I''ve added a patch which
2010 May 14
1
select method on ActiveRecord::Relation brakes enumeration
class Brake
scope :good, where(:quality => ''good'')
end
Brake.all.select &:nil? #=> works fine
Brake.good.select &:nil? #=> FAILS
Last statement fails because Brake.good.select is returning
ActiveRecord::Relation and not an array.
I have posted a detailed discussion on ticket #4589 .
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 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\"
2010 Apr 29
0
Precision issue with date parsing in ActiveRecord
Hello all,
I just recently opened supplied a patch for ticket #4498 (https://
rails.lighthouseapp.com/projects/8994/tickets/4498-rails-loses-
precision-when-deserializing-timestamps-from-postgresql). In short,
the current microsecond calculation converts a rational to a float,
then to an integer, occasionally causing rounding error. I''ve
supplied a patch against 2-3-stable (should also
2011 Mar 19
0
ActiveRecord::Relation#except and #only loses scope extensions
Hi,
I''ve written a patch to fix a bug in except and only on
ActiveRecord::Relation to lose any extensions added by earlier scopes.
Since making a pull request is erroring on my on github, I''ve added
the patch to lighthouse too.
This can be added to the Rails 3.0.x branch as well.
https://github.com/iain/rails/commit/a0bd5ba2fa38155ef6c036b256b08414eb9a2af1
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,
2010 Jun 09
1
[patch] fix bytesize in exception template; multibyte titleize
Hi all,
I wanted to draw some attention to a couple of very small multibyte-related
patches I believe should be included before Rails 3.0 RC1:
* Use String#bytesize rather than String#length in exception templates:
This is a simple case where string length is checked, but bytes is needed,
so it breaks with string with multibyte chars.
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.
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
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 Apr 18
1
Add shorthand support for routes like /projects/status(.:format)
Hi, when trying to migrate Signal to Rails 3 I tried to use the shorthand
route for:
match ''/projects/status(.:format)''
but it thrown an error because the controller was not specified. This
happend because actually the shorthand routes only work with routes without
optional parameters. The modification to support routes ending with a
optional parameters is very simple, as can
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