Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behaviour of format.amf with :include #7

Closed
wbDevel opened this issue Mar 8, 2011 · 2 comments
Closed

Unexpected behaviour of format.amf with :include #7

wbDevel opened this issue Mar 8, 2011 · 2 comments

Comments

@wbDevel
Copy link

wbDevel commented Mar 8, 2011

Hi,
I have following models:

class C1 < ActiveRecord::Base
  has_many :c2s, :include =>> :c3s
end
class C2 < ActiveRecord::Base
    belongs_to :c1       
    has_many :c3s
end
class C3 < ActiveRecord::Base
    belongs_to :c2
end

In my Controller I am doing the following:

......
@c1s = C1.find(:all, :include => [:c2s] )

logger.debug "**********: #{@c1s[0].c2s[0].c3s}"

respond_with(@c1s) do |format|
        format.amf { render :amf => @c1s.to_amf(:include => [:c2s] ) }
end
....

In my Logfile I can find the correct Output from the logger, but the respond_with block is sending back all c1s with the nested c2s - but NO c3s.
I tried a lot, but had no reasonable result. Is there something wrong with the deserialization - or is there another way getting back all three levels of objects ?

Thanks and Regards
Chris

@warhammerkid
Copy link
Owner

This functionality is actually provided by the rails3-amf gem (or if you somehow got your hands on the rubyamf-experiment gem), not the RocketAMF gem. That said, below is the proper call to to_amf to get c3s included. These call options are exactly the same as what you would use to serialize to JSON or XML.

@c1s.to_amf(:include => {:c2s => {:include => :c3s}})

@wbDevel
Copy link
Author

wbDevel commented Mar 8, 2011

Thanks a lot - and sorry, for posting this to the wrong Project. I intended to put it to rails3-amf.

Regards

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants