You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two (Rails) applications: One is using ActiveRecord, the other is not.
In the DB-backed app I have models like:
class Post < ActiveRecord::Base
has_many :comments
include ROXML
xml_attr :id
xml_attr :body
xml_attr :comments, :as => [Comment], :in => "comments"
end
class Comment < ActiveRecord::Base
belongs_to :post
include ROXML
xml_attr :id
xml_attr :body
xml_attr :post, :as => Post
end
In the non-AR-based app, which will consume the XML generated from the AR-based app, I have:
class Post
include ROXML
xml_accessor :id
xml_accessor :body
xml_accessor :comments, :as => [Comment]
end
class Comment
include ROXML
xml_accessor :id
xml_accessor :body
xml_accessor :post, :as => Post
end
The problem is, when I try to generate the XML, I (not so unexpectedly) get this:
>> Post.first.to_xml.to_s
SystemStackError: stack level too deep
So the question is: How to map ActiveRecord objects (with associations) to non-ActiveRecord objects using ROXML?
In the app not using ActiveRecord, I'd like to be able to go through relations, such as in:
the_post.comments.post.name
Not sure if this is possible, but I'd appreciate your insight.
Cheers.
-Chris
The text was updated successfully, but these errors were encountered:
Forget the SystemStackError: The circular reference is probably not the way to go.
However, another question: ROXML overrides ActiveRecord's to_xml method and I was wondering if there was a way to get the XML that would be generated by ActiveRecord's to_xml() instead of ROXML's to_xml()?
Hi there.
I have two (Rails) applications: One is using ActiveRecord, the other is not.
In the DB-backed app I have models like:
In the non-AR-based app, which will consume the XML generated from the AR-based app, I have:
The problem is, when I try to generate the XML, I (not so unexpectedly) get this:
So the question is: How to map ActiveRecord objects (with associations) to non-ActiveRecord objects using ROXML?
In the app not using ActiveRecord, I'd like to be able to go through relations, such as in:
Not sure if this is possible, but I'd appreciate your insight.
Cheers.
-Chris
The text was updated successfully, but these errors were encountered: