rails3-amf problem with serialization of associations

12 views
Skip to first unread message

ag

unread,
Feb 21, 2011, 6:00:33 AM2/21/11
to rubyamf
Hello all
I am a newbie to rails3-amf.. and also a bit newbie to ruby.
I have a testing ror-flex application with 3 models: User,Assignment
and Idea
Assignment is a pair of 1 User and 1 Idea (Belongs to)
User can have many assignments.
I also have a HAS_MANY_THROUGH property named ideas on the user class
(through assignments)
Same goes for Idea.. it has many assignments and HAS_MANY_THROUGH
users


I am creating at the flex client side a user object along with
assignments and ideas and send it to the server for persistence to the
DB.. this is my code:

def modify
@item = params[0]
@item.save!
@out = User.joins(:ideas,:assignments =>
[:user,:idea]).includes(:ideas,:assignments =>
[:user,:idea]).find(@item.id)
respond_with (@out) do |format|
format.amf {render :amf => @out.to_amf(:except
=>[:updated_at, :created_at], :include => [:ideas, :assignments])}
end
end

I get in reply a User object with an assignments and ideas
arrays..which have the proper children..however.. the idea and user
field of each Assignment object are null.

The idea array is filled with idea objects, however..the array fields
of those objects are null (users,assignments)..

This is like a 1-2 levels of association nesting... What am I doing
wrong? Is this the correct behaviour? How can I fix it so all my
references will be filled? Or is it not possible due to some circular
reference problem? (User=>Assignment =>Idea => Assignment =>User)?

Thanks in advance
Afik





Reply all
Reply to author
Forward
0 new messages