Flex on Rails book source code updated for Rails 2.3.2

Sunday, May 3, 2009

Rails 2.3.2 introduces some changes that required that we adapted the code from our book. I just reviewed and update the code for chapter 2,3,4,7,18,20 and 22 to run with Rails 2.3.2 and Flex SDK 3.3. Tony will do some more work on checking RubyAMF and the chapters he wrote code for. So here is quick look at the changes:

- In Rails 2.3.2 the file containing the application controller class must be renamed from application.rb to application_controller.rb.

- Another change introduce since the new rack middleware stack is that adding _method=put to the url isn't recognized by rails in the case of a post. However it's still recognized for the delete, so I am not sure what's going on and if the Rails guys will reinstate the _method= in the near future. Fortunately Rails recognizes the X_HTTP_METHOD_OVERRIDE request header. So for updates we set this header in Flex. Now Flex doesn't set the headers if the body of the message is empty like for delete, so we still use the _method=delete for deletes. It would be nice to be able to set this in a consistent manner for both deletes and updates.

- On chapter 04 on testing with Fluint we moved to using fluint 1.1.1, and no changes was require for this.

- On chapter 20 Server Push with Juggernaut I updated using the latest plugin downloaded from github and no more the code from rubyforge and updated gem version for eventmachine to 0.12.6 and the json gem to 1.1.4. So installing the plugin is now done with the following command:


./script/plugin install git://github.com/maccman/juggernaut_plugin.git


If you find any other issues with Rails 2.3.2. send me an email or leave a comment on this blog post. Thanks to all the readers that submitted comments so far.

Enjoy!
Daniel

Labels: ,

3 Comments:

Blogger Unknown said...

Hi,
Thanks for showing how to use the X_HTTP_METHOD_OVERRIDE to take into account the changes with Rails 2.3.2. I could not get the code in the book to work prior to seeing your updated code. However, I don't seem to be getting the error checking to work. That is, the code in application_controller.rb does not convert the 422 error into a 200 when the first or last name is missing. All I get is the Alert associated with fault="mx.controls.Alert.show(event.toString())";
Am I misunderstanding how this is supposed to work?

Thanks,
Vern

June 2, 2009 at 8:00 PM  
Blogger Unknown said...

Hi,

I found the error. It was in my app/controllers/people_controller.rb

For the update definition,I did not comment out ":status=>unprocessable_entity"
else
format.html {render: action=> "edit" }
format.xml {render:xml=>@person.errors,:status=>:unprocessable_entity}

Sorry, I could not get the last part to fit on a line, but I think you can see what I mean. Right after @person.errors should have been commented out.

Vern

June 3, 2009 at 8:47 AM  
Blogger Unknown said...

Hey,

Im having a problem getting RubyAmf to work with Rails 2.3.2 and higher. Have you come across similar issues?

Thanks,

Steve

August 18, 2009 at 3:45 PM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home

© 2008 Flex On Rails. All Rights Reserved