Alright, the problem seems to be that ROXML uses the Object#allocate
to generate objects, and never calls #initialize on those objects,
owing to the fact that you would want to initialize differently in a
world where your attributes are already initialized than in one where
they are not (which is the base #new case). There's a workaround
though, which I haven't tested but which will definitely solve the
immediate problem. That is to implement the #xml_initialize method on
your objects, and in it, call the regular #initialize, like so:
class RoxmlClass < ActiveRecord::Base
include ROXML
def self.xml_initialize
initialize
end
end
#xml_initialize (http://roxml.rubyforge.org/rdoc/classes/ROXML/
InstanceMethods/Construction.html#M000010) is called at the end of
#from_xml, and can be used to do things like call initialize with the
data from your xml attributes, or whatever else.
Hope that helps, and I'll have something which handles this in a
general way out in the near future. Feel free to contact me directly
in the future. You'll find my email on the website:
http://empact.github.com/roxml/
On Feb 4, 9:33 am, Ben Woosley <[email protected]>
wrote:
> Hey Adam,
>
> I'll take a look at this later today and get back to you. I
> specifically haven't tested intermixingROXMland ActiveRecord (as you
> have with :waypoints). I suspect the problem is that I'm setting the
> instance variable rather than going through the proxy accessor. I'll
> post here again when I have that worked out.
>
> Or, if you're so inclined, you can dig into the code yourself. See the
> "instance_variable_set" line, line 586
> here:http://github.com/Empact/roxml/blob/c9a3d82827d6939fcc76fa354a52f8bc3...
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---