RubyAMF parameter parsing via ActionController::Base.param_parsers

3 views
Skip to first unread message

chris joakim

unread,
Apr 21, 2008, 12:29:49 PM4/21/08
to rubyamf
Folks -

I'd like to use the standard Rails 2 parameter parsing approach for
RubyAMF, such as the following ...

ActionController::Base.param_parsers[Mime::XML]
ActionController::Base.param_parsers[Mime::YAML]
ActionController::Base.param_parsers[Mime::AMF] <= add support for
this

and not have to define parameters in rubyamf_config.rb and
ClassMappings.register

Can this be implemented? It would increase usability.

Thanks

Luke Pillow

unread,
Apr 21, 2008, 12:45:45 PM4/21/08
to rub...@googlegroups.com
Hi Chris,

I understand exactly what you're asking.  I like to take the same approach of accessing a params hash in the rails controllers regardless of client, but send AR models from Rails to Flex.  I really don't care for the practice of sending AR instances back and forth between client and server.  It seems to get ugly/problematic fast and doesn't really coincide with "the rails way."

I'm currently working on documenting how to accomplish this along with an (functional, but incomplete) ActionScript generator.  I don't have time right now to go into to much detail, but feel free to check out the generator plugin at it's temporary svn location of http://www.treetrunkmedia.com/svn/plugins/rubyamf_quickly

After installing, you can generate ActionScript models based on your AR models... There's a little config that gets added to the rubyamf_config.rb that may explain more. 

Generate the models using ./script/generate action_script_models com.yourdomain.package --include-helpers

So say you have a generated Person class and you are using the AS3 generated helpers you can then do something like...

var myPerson:Person = new Person();
myPerson.name = 'Chris';
RubyAMF.call( 'PersonController', 'create', {person : myPerson.toParams()}, myResultHandler, myFaultHandler);

Again... it is still a work in progress, so I offer no guarantees at this point.

Let me know if you have any questions.  I'm in a rush right now, but will have time later to answer and provide more details.
Reply all
Reply to author
Forward
0 new messages