Ruby amf with rails 3

52 views
Skip to first unread message

Nate

unread,
Oct 12, 2010, 7:48:22 PM10/12/10
to rubyamf
I have a controller named facebook but when I make my call from flex
to grab some data from the controller i get

There was an error loading the service class FacebookController.

It seems to be failing on @service =
@amfbody.service_class_name.constantize.new in actions.rb in invoke I
am just not sure why. am I missing some configuration that wasn't
needed in the old version everything works fine on the old rails and
ruby amf

fosrias

unread,
Oct 13, 2010, 12:33:17 PM10/13/10
to rubyamf
Nate:

Not sure where your problem lies. Have stepped through my test
environment for Rails3 using rubyamf and don't have any problems, nor
can I see what might be causing your problem at line 96.

Do you have a debugger that you can check a couple points:

1. Put a break on line 177 in amf.rb after the @service_class_name is
set. What does it set the value to?
2. Put a break on line 96 in action.rb and set a watch on:
@amfbody.service_class_name.constantize. What does it give you?

Also, if you have a stack trace of the error that would help. Ruby
version?

Mark

Nate

unread,
Oct 13, 2010, 12:41:25 PM10/13/10
to rubyamf
It turns out I had a error in the controller once fixed it is working
fine. I am still having a issue tho is it possible to use respond_to
or respond_with. If i use either of these the body is always set to a
false boolean. but if I render :amf => @object the body is set to the
correct object.

Nate

unread,
Oct 13, 2010, 12:43:15 PM10/13/10
to rubyamf
It turns out I had a error in the controller once fixed it is working
fine. I am still having a issue tho is it possible to use respond_to
or respond_with. If i use either of these the body is always set to a
false boolean. but if I render :amf => @object the body is set to the
correct object.

On Oct 13, 10:33 am, fosrias <fosteri...@gmail.com> wrote:

philmill

unread,
Oct 26, 2010, 1:02:39 PM10/26/10
to rubyamf
Having a different issue with Rails 3.0.1. First off, I'm not new to
rubyAMF or rails and I've had a lot of fun with rubyAMF in the past
with rails2. I'm trying to start new with a fresh rails3 app. I use
RVM to manage my rubies and have tried the following experiment in the
latest REE and 1.9.2, both have failed with the exact same results.

Steps:
Generate new rails app, scaffold simple widget model with a name field
of type string.
Modify routes to point root to the widget index method.
Install plugin via "rails plugin install git://github.com/victorcoder/rubyamf_plugin.git"
Gateway logo shows up fine at localhost/rubyamf/gateway/
I added a simple hello world amf response to my index method by adding
format.amf { render :amf => 'hello world' } to the respond_to block.

Simple right?
Now when I try and hit that method, I get a null result. Here is the
strange thing, if I type localhost/widgets.amf in the browser then hit
that method I get my 'hello world' as expected.

Also when I try to render @widgets as amf, the rubyAMF PrepareAction,
RailsInvokeAction, and Serialization trigger but the returned index
gets processed as HTML!
Here is the output from the server:
>>>>>>>> RubyAMF >>>>>>>>> #<RubyAMF::Actions::PrepareAction:0x000000028c7088> took: 0.00009 secs
>>>>>>>> RubyAMF >>>>>>>>> #<RubyAMF::Actions::RailsInvokeAction:0x000000028c7060> took: 0.08593 secs
>>>>>>>> RubyAMF >>>>>>>>> Serialization took: 0.00004 secs


Started POST "/rubyamf/gateway/" for 192.168.10.1 at 2010-10-26
12:48:49 -0400
Processing by RubyamfController#gateway as HTML
Processing by WidgetsController#index as HTML
Widget Load (0.4ms) SELECT "widgets".* FROM "widgets"
Rendered widgets/index.html.erb within layouts/application (12.9ms)
Completed 200 OK in 36ms (Views: 20.1ms | ActiveRecord: 0.4ms)
Rendered text template (0.0ms)
Sent data (1.1ms)
Completed 200 OK in 90ms (Views: 1.0ms | ActiveRecord: 0.0ms)


Adding amf extension in the browser doesn't work for @widgets, in
either case, the server displays the same info. Rendering xml is
fine.

I use Flash CS5 and GutterShark to handle my amf services, works with
other services and has been proven to work with rubyAMF under an older
rails2 app.


Has anyone experienced this? Any input would be well welcomed.

Thanks in advance,
Phil

philmill

unread,
Oct 26, 2010, 1:37:51 PM10/26/10
to rubyamf


On Oct 13, 12:43 pm, Nate <nate.scave...@gmail.com> wrote:

Michael

unread,
Oct 26, 2010, 2:30:48 PM10/26/10
to rub...@googlegroups.com
Yes, I had same problem.
I have had to backburner this project until RubyAMF catches up with 3.0.n or
find another solution.

Thanks in advance,
Phil

--
You received this message because you are subscribed to the Google Groups
"rubyamf" group.
To post to this group, send email to rub...@googlegroups.com.
To unsubscribe from this group, send email to
rubyamf+u...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyamf?hl=en.

philmill

unread,
Oct 27, 2010, 12:27:46 AM10/27/10
to rubyamf
So I forked victorcoder's repo on github and merged marciogm's fork
(generator updates, http://github.com/marciogm/rubyamf_plugin ).
Manually installed from my merged fork, ran the install generator, and
ran the scaffold generator for a simple widget model with name field
of type string. I get the exact same results as just running
victorcoder's git install. "WidgetsController#find_all as HTML" not
amf. The scaffold generated controller doesn't even specify html as a
valid respond_to format.

Here's my fork.
http://github.com/philmill/rubyamf_plugin

rodrigob

unread,
Jul 14, 2011, 3:38:24 PM7/14/11
to rub...@googlegroups.com
I am having the same "as HTML" problem (using rails 3.1, ruby_amf version 1.6.6) , what was the solution to this issue ?

Started POST "/rubyamf_gateway" for 127.0.0.1 at 2011-07-14 21:14:02 +0200
  Processing by RubyamfController#gateway as HTML
  Processing by MyServiceController#echo as HTML

Thanks for your answers.
Regards,
rodrigob.

warhammerkid

unread,
Jul 14, 2011, 3:58:37 PM7/14/11
to rubyamf
The easiest solution is to not use Rails 3.X if you're using
rubyamf_plugin. If that's truly not an option, you have two choices.

1. You can try further patching of rubyamf. I have a feeling that
changing line 126 in actions.rb (https://github.com/philmill/
rubyamf_plugin/blob/master/app/actions.rb#L126) to
req.env['HTTP_ACCEPT'] = 'application/x-amf' will fix the issue.
That's what I've been doing in RubyAMF 2.0 (https://github.com/
warhammerkid/rubyamf-experiment/blob/master/lib/rubyamf/rails/
request_processor.rb#L34), but there may be other issues.

2. You can try to use RubyAMF 2.0 (https://github.com/warhammerkid/
rubyamf-experiment). However, documentation isn't finished, I cannot
guarantee any release dates, and I am not particularly interested in
holding hands yet if you can't figure out how to use it yourself.

I know that a lot of people would like to switch to Rails 3, but until
I finish work on RubyAMF 2.0 it's really not an option. I would
suggest that you try the suggested patch first, as I have a feeling
that it might fix your issue. If you'd like to help finish RubyAMF
2.0, I'd appreciate any feedback you can offer on the current
documentation and APIs.
Reply all
Reply to author
Forward
0 new messages