Registering the 2 class mapping giving different object format

4 views
Skip to first unread message

Mike Disuza

unread,
Oct 13, 2010, 8:51:02 AM10/13/10
to rubyamf
Hi,
I have added the two class mappings in my rubyamf_config.rb. like as
follow:-

ClassMappings.register(:actionscript => 'Entity', :ruby =>
'Entity', :type => 'active_record', :associations=>
["entity_type","addresses"], :methods => ["carousel_images",
"main_image", "quoted_price"])
ClassMappings.register(:actionscript => 'Car', :ruby =>
'Car', :type => 'active_record', :methods => ["carousel_images",
"main_image"])

Whenever I am printing the result object on flex side I am getting the
objects in two different format.

Is it the way the class mapping works?

Anyone have any thoughts.
Thanks,
Mike

fosrias

unread,
Oct 13, 2010, 9:55:56 AM10/13/10
to rubyamf
Mike:

Not sure what you mean by getting the objects in two different
formats. Your mapping should correspond to two distinct Actionscript
classes on the flex side whose RemoteClass alias metadata tag
correspond are 'Entity' and 'Car' respectively. The return should
deserialize to these specific class types. If all you are getting are
generic objects with the mappings and remoteclass tags set, then make
sure you have specifically referenced the classes in your flex app. If
you have not, the compiler does not include them and thus they are not
deserialized. As a practice, I do the following in all my apps in some
main controller or service class:

private var static remoteClasses:Array = [Entity, Car];

That way, the classes are always referenced vs. me forgetting to when
I am first checking my remoting and getting generic objects back.

Mark

Brent Bonet

unread,
Oct 13, 2010, 10:32:40 AM10/13/10
to rub...@googlegroups.com
Mark,

Thanks for that tip. I've been using private var _entityVO = new
EntityVO(); for each class which, while it works, causes a harmless
but annoying warning in Flex.

Brent

> --
> You received this message because you are subscribed to the Google Groups "rubyamf" group.
> To post to this group, send email to rub...@googlegroups.com.
> To unsubscribe from this group, send email to rubyamf+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rubyamf?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages