Alright, I found that this actually required a bit more to work properly, but if you look at my latest code: http://github.com/Empact/roxml/tree/master, I have a examples/active_record.rb, and spec/examples/active_record.rb to show it's working properly.
So install this latest version from my github and you should have things working. See the history: http://github.com/Empact/roxml/blob/a2434d5c14a31ec2099c38a6248b4fcf4e5f5565/History.txt for the changes involved. You should also get some deprecation warnings from this newest code. I'm preparing for a bit of an API shakeup in 3.0 which should be the last. In short, all type declaration come via the :as parameter, all location declarations come via :from and :in, all options come as separate arguments. The rdocs should be up to date on this. On Feb 5, 1:42 am, Ben Woosley <[email protected]> wrote: > Alright, the problem seems to be thatROXMLuses 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 > includeROXML > 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 -~----------~----~----~----~------~----~------~--~---

