Getting data from Rails to Flex

0 views
Skip to first unread message

julien

unread,
Dec 19, 2007, 7:48:12 AM12/19/07
to rubyamf
Hi All,

It's been a while since I haven't used RubyAMF, and since I'm still
learning Rails so I might have done something wrong ...
After installing the plugin with sciprt/plugin install etc... I just
added a method in my "main controller" that returns an array :
@users = User.find(:all)
and I'd like to send that back to Flex so I used :
render(:amf => @users)

This works but, when my "onResult" handler is called in Flex,
assigning a DataGrid's dataProvider property to the event.result
property gives me an object with 'attributes' and 'attributes_cache'
objects inside it ... I can still access what I want inside that
attributes object but what I'd like to do is get the 'attributes'
object directly and set that as my dataProvider, is there a "better"
way to do this? examples? what am I doing wrong? :)

Thanks for your help


Julien

Tony Hillerson

unread,
Dec 19, 2007, 12:36:31 PM12/19/07
to rubyamf
Sounds like you don't have a class mapping set up for User to an
Actionscript class. Read the Class Mapping section of your config/
rubyamf_config.rb and see if that sheds any light on the problem.

Cliff Rowley

unread,
Dec 19, 2007, 1:13:49 PM12/19/07
to rub...@googlegroups.com
Hello mate! :-)

It sounds like you haven't got your VO mappings set correctly. The
attributes hash is actually from Rails (my_obj.attributes). If you're
online today give me a buzz on msn and I'll throw you a handy little
script I use to generate VO and parameter mappings from a YML
description :-)

Cliff

Julien Castelain

unread,
Dec 19, 2007, 2:40:41 PM12/19/07
to rub...@googlegroups.com
Hey :)

Thanks or the reply, I'll start  looking at that now ,

@Cliff, I'll give you a shout asap :)

Julien

Todd Johnson

unread,
Dec 20, 2007, 3:05:15 PM12/20/07
to rubyamf
Hey Cliff, is there anyway I could get a copy of that script? It
sounds very useful!
Thanks

Cliff Rowley

unread,
Dec 20, 2007, 3:57:02 PM12/20/07
to rub...@googlegroups.com
On 20 Dec 2007, at 14:05, Todd Johnson wrote:

>
> Hey Cliff, is there anyway I could get a copy of that script? It
> sounds very useful!
> Thanks

Sure thing! It's pretty ugly and hacked together Ruby code, but it
suffices for the time being. It's also relatively specific to our
project so you may need to edit it a little. Our project is a little
hush hush for the time being, so I'll also need to doctor it a little
to remove specific references - but I'll try to do that today if I get
a chance. If not, then tomorrow :-)

My development partner is actually a much more proficient Ruby
programmer than I am so perhaps at some point he'll refactor it and
make it pretty and more generically useful.

Cliff

Reply all
Reply to author
Forward
0 new messages