BelongsTo(polymorphic="true") and namespaces in RoR

10 views
Skip to first unread message

scho

unread,
Jan 26, 2011, 4:26:37 AM1/26/11
to restfulx-framework
Hi Dima,

I found out, that there's a problem with polymorphic associations and
namespaces. For example, if your ruby class is called 'Vehicles::Car'
and your AS class 'Car', polymorphic belongs-to relationships does not
work.

I've tried to get along with that issue on rails side by trying to
return just 'Car' as object_type, but in the end, it led to nothing,
especially when you want to include the polymorphic association in
to_fxml.

I think, the only way, to solve that issue, is to remove the
namespaces on Flex side. On Rails side, the following adds the
namespaces again:

FLEX_TO_RAILS_CLASSES_MAP = {"Car" => "Vehicles::Car"}

def object_type=(value)
if FLEX_TO_RAILS_CLASSES_MAP[value]
value = FLEX_TO_RAILS_CLASSES_MAP[value]
end
super value
end

I've already tried to implement this in the restfulx_framework and it
seems to work.
So Dima, if you agree with that solution, I will commit my code and
send you a pull request!

Georg

iRonin

unread,
Mar 8, 2011, 6:13:07 AM3/8/11
to restfulx-framework
Hi Georg,

Is your code available anywhere?

Thanks,
Cyprian
Reply all
Reply to author
Forward
0 new messages