RubyAMF 1.5

1.5 is now in edge / trunk. We changed so much I don’t have a comprehensive change-log for you. The first thing to check out with 1.5 is the configuration file. Enjoy! -Aaron

Martin said,

November 13, 2007 @ 15:48

So how exactly do I get at 1.5? I don’t see an edge/trunk directory in the svn repo…

aaron said,

November 13, 2007 @ 16:42

for general SVN:
svn checkout http://rubyamf.googlecode.com/svn/trunk/

rails installer:
ruby script/plugin install http://rubyamf.googlecode.com/svn/trunk/rubyamf

Neer Friedman said,

November 14, 2007 @ 00:13

Hi Aaron !
Great work, I found a small thing to fix in the RubyamfController, change:

amf_response = if request.env['CONTENT_TYPE'].to_s.match(/x-amf/)
headers['Content-Type'] = “application/x-amf”
RailsGateway.new.service(request.raw_post) #send the raw data throught the rubyamf gateway and create the response
else
welcome_screen_html # load in some stub html
end

#render the AMF
send_data(amf_response, :type => ‘application/x-amf’)

to:

amf_response = if request.env['CONTENT_TYPE'].to_s.match(/x-amf/)
headers['Content-Type'] = “application/x-amf”
RailsGateway.new.service(request.raw_post) #send the raw data throught the rubyamf gateway and create the response
else
welcome_screen_html # load in some stub html
end

#render the AMF
send_data(amf_response, :type => ‘application/x-amf’)

this way the gateway html will work when you try to access it with a normal browser request.

Sonny said,

November 14, 2007 @ 09:54

Quick question:

I am sending back a query for a datagrid dataprovider.

I thought I would be able to do this:

dg.dataProvider = re.result //re being the ResultEvent

do I have to do a re.result as ArrayCollection? I thought that I wouldn’t have to do any type casting since its an AMF object?

Thanks.

aaron said,

November 14, 2007 @ 10:29

@sonny,

Check out the “Use Array Collection” section in the rubyamf configuration. This will send back array collections. Otherwise you get an array.

The reason you have to cast it (dg.dataProvider = Array(re.result)) is because the “result” property on the ResultEvent is typed as an object so that any result can be placed in it.

-Aaron

aaron said,

November 14, 2007 @ 14:22

the rubyamf controller fix should be:

amf_response = if request.env['CONTENT_TYPE'].to_s.match(/x-amf/)
headers['Content-Type'] = “application/x-amf”
RailsGateway.new.service(request.raw_post) #send the raw data throught the rubyamf gateway and create the response
else
headers['Content-Type'] = “text/html”
welcome_screen_html # load in some stub html
end

#render the AMF
send_data(amf_response, :type => headers['Content-Type'], :disposition=>’inline’)

Sonny said,

November 15, 2007 @ 08:31

Aaron,

So I uncommented the following:

ClassMappings.use_array_collection = true

and restart mongrel. It still looks like it is coming over as an Array.

Is there somewhere I need to change?

Thanks.

aaron said,

November 15, 2007 @ 10:52

You also should cast to ArrayCollection specifically. myDP = re.result as ArrayCollection

Sonny said,

November 15, 2007 @ 11:32

yeah I already did that..this is what I have:
:ROR
def list
@users= User.find_all_users
#render :x ml => @users.to_xml(:dasherize => false)
render :amf => @users
end
:FLEX

:actionscript
private function listResultHandler(re:ResultEvent):void {
trace(”Got result:” + re.result);
dg_user.dataProvider = re.result as ArrayCollection;
}
:datagrid

Sonny said,

November 15, 2007 @ 12:41

sorry to bother you but i feel real close in getting this working…

So this:
private function listResultHandler(re:ResultEvent):void {
trace(”Got result:” + re.result);
userArrayCol = re.result as ArrayCollection;
trace(userArrayCol);

}

gives me this in the flex builder debugger:
Got result:[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
null

I turned off use_array_collection since it wasn’t really helping. But I should be able to cast Array into an ArrayCollection…right?

aaron said,

November 15, 2007 @ 19:37

yeah that’s right. I’m not sure what the “null” is in there. that’s interesting. but yea you’re stuff looks fine. what’s the problem?

Sonny said,

November 19, 2007 @ 14:07

Its weird…when I cast the amf response the response disappears. I try to get a length and it returns null.

I can do a length on the re.result but not after the cast.

Neer Friedman said,

November 20, 2007 @ 23:46

sonny:
When you try to cast the re.result to ArrayCollection you need to do it with:
dg_user.dataProvider = new ArrayCollection(re.result);
** Notice the ‘new’ directive **

Sonny said,

November 21, 2007 @ 07:55

1118: Implicit coercion of a value with static type Object to a possibly unrelated type Array.

Looks like the ArrayCollection is expecting an Array object…

Neer Friedman said,

November 22, 2007 @ 06:16

No problem, just tell him:
dg_user.dataProvider = new ArrayCollection(re.result as Array);
and make sure you really do send an array from the ruby side.

RSS feed for comments on this post · TrackBack URI

Leave a Comment