Daniel Passos
unread,Feb 22, 2008, 3:07:49 PM2/22/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rub...@googlegroups.com
Hi All!
I'm going crazy. I created a simple project to test RubyAMF, but it's not working. The RubyAMF isn't returning a Typed Object.
Any suggestion?
AS Model
package
{
public class Console
{
public var id:Number;
public var nome:String;
}
}
Active Record
class Console < ActiveRecord::Base
end
Active Controller
class ConsolesController < ApplicationController
def index
@consoles = Console.find(:all)
respond_to do |format|
format.amf { render :amf => @consoles }
end
end
end
rubyamf_config
ClassMappings.ignore_fields = ['created_at','created_on','updated_at','updated_on']
ClassMappings.translate_case = true
ClassMappings.force_active_record_ids = true
ClassMappings.assume_types = false
ClassMappings.register(
:actionscript => 'Console',
:ruby => 'Console',
:type => 'active_record',
:attributes => ["id", "nome"]
)
Flex Application
<mx:RemoteObject id="consoleService" source="ConsolesController" fault="onFault(event)" destination="rubyamf-service">
<mx:method name="index" result="consoleResultList(event)" fault="onFault(event)" />
</mx:RemoteObject>
public function createConsole():void
{
var console:Console = new Console();
console.nome = "XBox 360";
consoleService.send();
}
public function consoleResultList(event:ResultEvent):void
{
listaConsoles.dataProvider = event.result;
}
<mx:Button label="Go!" click="consoleService.index.send()" />
<mx:DataGrid id="listaConsoles" />
Result Debug
this acervo_flex (@b2d30a1)
event mx.rpc.events.ResultEvent (@b146d01)
[inherited]
headers null
result Array (@b35a191)
[0] Object (@b1c80b1)
attributesCache Object (@b2fd241)
createdAt Date (@b2f8ca1)
id 1
nome "PS2"
updatedAt Date (@b2f8401)
length 1