Still needing simple setup instructions...

73 views
Skip to first unread message

MichaelG

unread,
Nov 10, 2010, 6:17:12 PM11/10/10
to rubyamf
So, it's been 2 months since this request... lets try again.
Since I've tried other technologies that just hit a wall, I am still
looking for something to work to get Flex 4 to do Restful CRUD with
Rails 3.

This was most promising but I can't get a simple app to work.

PLEASE:
1) create a Rails 3 app with 2 models to allow showing configuration
of a has_many relationship.
2) create a simple Flex 4 app that connects to it and shows (Users and
when clicking on a user, shows that users Courses (using your config
example from Github.).
3) Create a GitHub repo with these examples. I would be HAPPY to
contribute once I can get any of this working.

philmill

unread,
Nov 11, 2010, 11:27:28 AM11/11/10
to rubyamf
I can't get rubyAMF to work with any Rails3 app. I got the generators
to work thanks to marciogm on github, but even the most simple test
would return html instead of amf. I use Flash and GutterShark to
create services and that is all my test swf does. It works fine for
Rails2. See my notes at http://groups.google.com/group/rubyamf/browse_thread/thread/eab981f74735da52

I also played around with warhammerkid's rails3-amf
http://github.com/warhammerkid/rails3-amf. I followed the readme but
had some issues with the plugin which I think is related to my RVM
install and not the plugin. To check it is working run 'rails console'
in your app and then type 'Mime::AMF'. You should get something like
the following.

Loading development environment (Rails 3.0.1)
>> Mime::AMF
=> #<Mime::Type:0x10117ca80 @string="application/x-amf", @symbol=:amf,
@synonyms=[]>
>>

If any of those instance vars are missing, something is wrong (in my
case only '=> application/x-amf' displays). His plugin doesn't require
a specific controller by bypassing the regular rails3 routes (we can
thank RyanWilliams at github for the following info).


So far, I too am stuck in the water without rubyamf support for Rails3
and it sucks. I haven't had much spare time to deal with this either
so any help would be great.

warhammerkid

unread,
Nov 11, 2010, 12:15:48 PM11/11/10
to rubyamf
I've been incredibly busy at work preparing for an enormous product
launch, and that has pretty much robbed me of any spare time I would
have had for this. I'm going to try to put some time aside right after
the launch to put together some stronger documentation and a starter-
project example, but it's going to take some time. I hadn't really
expected anyone to move to Rails 3 quickly, and for those who did I
expected them to be familiar enough with ruby and rails to figure it
out on their own. If you're interested in digging into the code, the
best thing to do would be to start with the tests/specs, as they give
the exact code to use when performing a specific task. For example, in
rails3-amf, spec/serialization_spec.rb contains the exact code for
serializing a user with all the courses they have -
@user.to_amf :include => "courses". Other than that, you'll just have
to wait until I have more time, or until someone else puts it
together.

Stephen

On Nov 11, 11:27 am, philmill <philmill....@gmail.com> wrote:
> I can't get rubyAMF to work with any Rails3 app. I got the generators
> to work thanks to marciogm on github, but even the most simple test
> would return html instead of amf. I use Flash and GutterShark to
> create services and that is all my test swf does. It works fine for
> Rails2. See my notes athttp://groups.google.com/group/rubyamf/browse_thread/thread/eab981f74...
>
> I also played around with warhammerkid's rails3-amfhttp://github.com/warhammerkid/rails3-amf. I followed the readme but

philmill

unread,
Nov 16, 2010, 12:37:45 PM11/16/10
to rubyamf
@Stephen
Thanks for all that you have done. RocketAMF and rails3-amf are a huge
step forward, super cleaver and most certainly beyond my skill set.
Unfortunately for me and I'm guessing a lot of Rails novices, our
Rails skills are better than the inherent Ruby skills. I have built
Rails apps with nested model relationships and mostly code by example.
I didn't mean to sound unappreciative, I'm more disappointed in my
commitment to learning Ruby. I'll try to dive deeper into your work
and thanks for the spec tip.

Sincerely,
Phil

fosrias

unread,
Nov 18, 2010, 4:31:41 PM11/18/10
to rubyamf
Added a demo per http://groups.google.com/group/rubyamf/browse_thread/thread/f16f29c4352d1ec9.
Note that this is not with stephen's version, but the patched version
of legacy RubyAMF that has the full activerecord support.

Atomic

unread,
Nov 19, 2010, 3:17:11 AM11/19/10
to rubyamf
Hi,

Usually with warhammerkid's amf, the issue usually is with bundle
install where the version on Github is not checked out. So you will
have to get both rails3-amf and rocket-amf, keep them locally within
your rails app and then modify your Gemfile to use the locally
installed versions. for example, in my application, I pulled down the
two files and kept them in my vendor/bundle folders. Then I modified
the file entry as below

gem 'RocketAMF', :path => File.join(File.dirname(__FILE__), '/vendor/
bundle/rocket-amf')
gem 'rails3-amf', :path => File.join(File.dirname(__FILE__), '/vendor/
bundle/rails3-amf')


Afterwards, run sudo bundle install and that is it - rails3amf
running.

To use, rails3-amf, simply state your respond_to within the controller
as in the example below

respond_to do |format|
# format.html # show.html.erb
#format.xml { render :xml => @search }
format.amf { render :amf => @search }
end


To connect from Flex, set the services address to http://localhost:3000/amf
and voila! your flex apps starts consuming.

Let me know where you have problems may be I can help. That is the
least I can do back in return for using warhammerkids rails3-amf.

Regards,
Ademola



On Nov 11, 5:27 pm, philmill <philmill....@gmail.com> wrote:
> I can't get rubyAMF to work with any Rails3 app. I got the generators
> to work thanks to marciogm on github, but even the most simple test
> would return html instead of amf. I use Flash and GutterShark to
> create services and that is all my test swf does. It works fine for
> Rails2. See my notes athttp://groups.google.com/group/rubyamf/browse_thread/thread/eab981f74...
>
> I also played around with warhammerkid's rails3-amfhttp://github.com/warhammerkid/rails3-amf. I followed the readme but

philmill

unread,
Nov 20, 2010, 2:57:44 PM11/20/10
to rubyamf
Ok this time I made sure my RVM terminal was always defaulted to ruby
1.9.2 and using rails 3.0.2.

I created a fresh app and installed the patched rubyAMF and still
getting results as HTML and my entire index view rendered.

I created the same app and followed Atomic's instructions for rails3-
amf and got AMF objects back! The crowd goes wild.
Just for consistency I created the same app and pointed to git instead
of my local file system and I get the following error "10301: Unknown
type: 19."

Thanks to all for their work into this endeavor.


Cheers,
Phil


On Nov 19, 3:17 am, Atomic <osind...@yahoo.co.uk> wrote:
> Hi,
>
> Usually with warhammerkid's amf, the issue usually is with bundle
> install where the version on Github is not checked out. So you will
> have to get both rails3-amf and rocket-amf, keep them locally within
> your rails app and then modify your Gemfile to use the locally
> installed versions. for example, in my application, I pulled down the
> two files and kept them in my vendor/bundle folders. Then I modified
> the file entry as below
>
> gem 'RocketAMF', :path => File.join(File.dirname(__FILE__), '/vendor/
> bundle/rocket-amf')
> gem 'rails3-amf', :path => File.join(File.dirname(__FILE__), '/vendor/
> bundle/rails3-amf')
>
> Afterwards, run sudo bundle install and that is it - rails3amf
> running.
>
> To use, rails3-amf, simply state your respond_to within the controller
> as in the example below
>
> respond_to do |format|
>      # format.html # show.html.erb
>       #format.xml  { render :xml => @search }
>       format.amf  { render :amf => @search }
> end
>
> To connect from Flex, set the services address tohttp://localhost:3000/amf

Mark W. Foster

unread,
Nov 20, 2010, 5:59:31 PM11/20/10
to rub...@googlegroups.com
Phil:

Do you have your source code available to look at on Github?

Mark


Cheers,
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.

fosrias

unread,
Nov 20, 2010, 6:03:19 PM11/20/10
to rubyamf
I have a guess that you are using:

respond_to :amf

in your controller. Is this correct? I have not added that to RubyAMF
but will try to today.

Mark

warhammerkid

unread,
Nov 20, 2010, 6:04:21 PM11/20/10
to rubyamf
A couple things to address:

I can't really comment too much on rubyAMF, but I suspect that the
reason why it isn't working has to do with the HTTP_ACCEPT header not
being set by flash and rails 3 defaulting to html if there are more
options than just AMF and it can't figure out what to send back. For
what it's worth, I tried to use fosrias's rubyamf example application,
but it doesn't work and appears to responding with HTML for me as
well. I did my testing by loading the compiled SWF directly using fdb,
so it's possible that running it inside an HTML wrapper will fix this.

Now those of you who follow Atomic's instructions and don't use
bundler to install the gems are not going to be using the native
extensions, as they don't get compiled. This shouldn't have any effect
on whether it works or not because I've tested with both the native
extension and the ruby code, but it will be slower. With that said,
I'm hoping to have an example application for rails3-amf up on github
before the end of the weekend and I'll see if I run into any issues
getting that up.

Mark W. Foster

unread,
Nov 20, 2010, 7:29:36 PM11/20/10
to rub...@googlegroups.com
Hi Stephen:

Can you give me some more details on how you were launching it to get this
failure mode. Thanks.

Mark

-----Original Message-----
From: rub...@googlegroups.com [mailto:rub...@googlegroups.com] On Behalf
Of warhammerkid
Sent: Saturday, November 20, 2010 3:04 PM
To: rubyamf
Subject: [RubyAMF] Re: Still needing simple setup instructions...

--

Atomic

unread,
Nov 21, 2010, 1:26:11 PM11/21/10
to rubyamf
Hi Stephen (warhammerkid),

While building your sample application, just try to watchout for the
main gotchas - sudo bundle install with your files on Github. They are
not checking out and that was the more reason I cloned them locally
and pointed to the local versions in the Gemfile. You could look into
fixing that.

Regards,
Ademola Osindero

philmill

unread,
Nov 21, 2010, 1:27:49 PM11/21/10
to rubyamf
Mark, I created a demo app and pushed it to github.
http://github.com/philmill/rubyAMF-demo
I'm using format.amf { render :amf => @myModel } in my respond_to
block exactly like your demo.

I just set up a simple widget model with a title attribute of type
string. It is also the root route. I set up a dummy html file to house
the test swf found at public/test.html. The flash source is located
at /flashSrc. I'm using Guttershark to send requests so look at public/
model.xml to see the path and endpoint.


Stephen, I'm not sure why running bundle install from remote isn't
working for me. Are you using RVM?


Gentlemen, thanks for all you time.

Michael

unread,
Nov 22, 2010, 2:35:13 PM11/22/10
to rub...@googlegroups.com
Thank you to all who work on this!!!!

I've tried this to no avail...

FLEX:
var token:AsyncToken;
token = AsyncToken(myService.index());
token.message.headers['Content-Type'] = 'application/x-amf';
token.message.headers['HTTP_ACCEPT'] = 'application/x-amf';


Rails 3.0.1 in controller:
This will render my AMF objects, but also logs layouts with headers/footers
n such. killing performance advantages
def index
if is_amf
render :amf => @policies, :class_mapping_scope => :viewing, :layout =>
false
else
respond_to do |format|
format.amf { render :amf => @policies, :layout => false }
#format.html {logger.info ("Policies#index html")}
#format.xml { render :xml => @policies.to_xml(:dasherize =>
false) }
end
end
end

Rails 3.0.1 in same controller:
This results in 406 "Not acceptable" and no AMF is returned.

def index
respond_to do |format|
format.amf { render :amf => @policies, :layout => false }
format.html {logger.info ("Policies#index html")}
format.xml { render :xml => @policies.to_xml(:dasherize => false) }
end
end

Here is a log snippet:


At least for now I can continue working on this project and get some other
thing accomplished.
This won't work for production releases though.

Michael.

Michael

unread,
Nov 22, 2010, 2:39:24 PM11/22/10
to rub...@googlegroups.com
Log Snippet (for previous email):
 
Started POST "/rubyamf/gateway" for 192.168.1.12 at 2010-11-22 11:21:35 -0800
  Processing by RubyamfController#gateway as HTML
  Processing by PoliciesController#index as HTML
  Policy Load (3.3ms)  SELECT `policies`.* FROM `policies` WHERE (client_id = 1)
Rendered shared/_header.html.erb (148.5ms)
Rendered policies/index.html.erb within layouts/application (208.0ms)
Completed 200 OK in 263ms (Views: 213.1ms | ActiveRecord: 16.9ms)
Rendered text template (0.0ms)
Sent data  (22.6ms)
Completed 200 OK in 692ms (Views: 22.4ms | ActiveRecord: 0.0ms)
 
 
 
-----Original Message-----
From: philmill
Sent: Sunday, November 21, 2010 10:27 AM

fosrias

unread,
Nov 29, 2010, 11:31:52 PM11/29/10
to rubyamf
@philmill

I just put a patch in RubyAMF in my demo here: https://github.com/fosrias/rubyamf-rails3-demo

I have another demo at my github site so don't get them mixed up, but
I wondered if you could try to see the if demo works in your
environment (i.e. does not render to html) before I push the patch to
the RubyAMF trunk.

Thanks.

Mark

On Nov 21, 10:27 am, philmill <philmill....@gmail.com> wrote:
> Mark, I created a demo app and pushed it to github.http://github.com/philmill/rubyAMF-demo
Reply all
Reply to author
Forward
0 new messages