AjaxScaffold and Rails 1.2.1
January 22nd, 2007
There is an issue with the latest release of Rails and AjaxScaffold. Well actually the problem is in a conflict between Prototype and Rico Corner, if you find that all the AJAX stops working – lots of spinning indicators and not much else you have three choices, wait a little and we will likely release an update, or if you are impatient / desperate for a fix you can use the following patch for prototype or you can remove the Rico Corner include…...
Patch Prototype
Simply open prototype.js and around line 915 replace this:for (var name in headers) this.transport.setRequestHeader(name, headers[name]);
with this:
for( var name in headers ) {
if( typeof( headers[name] ) != 'function' ) {
this.transport.setRequestHeader(name,headers[name]);
}
}
and all should be well again.
Remove Rico
Open up the ajax_scaffold_plugin.rb file in vendor/plugins/ajaxscaffoldp (or wherever it was installed) and at the bottom remove the ‘rico_corner’ include from this method:
def ajax_scaffold_includes
js = javascript_include_tag(:defaults, 'rico_corner', 'ajax_scaffold', 'dhtml_history')
css = stylesheet_link_tag('ajax_scaffold')
js + "\n" + css
end
You should also remove the call to Rico.corner in table.rhtml, now all should function again just without rounded corners…..
November 25th, 2007 at 11:18 PM I've had this problem with Rails 1.2_rcX for some time. I always reverted back to Prototype 1.5_rc1 which didn't seem to have these issues. Of course, these solutions are far more easier to apply.
November 25th, 2007 at 11:18 PM Hi Ariejan, there is now a release that fixes all this for you: 3.2.3. Cheers Scott.
November 25th, 2007 at 11:18 PM I'm still having this problem after trying these fixes? What should I do next?
November 25th, 2007 at 11:18 PM btw, I'm using the following versions: Rails 1.2.1 Prototype 1.5.0 Ajax Scaffold 3.2.4 I tried using Prototype 1.5.0_rc0, didn't work...
November 25th, 2007 at 11:18 PM Scott, I recently switched over to Rails 1.2.2 and migrated from the generator to the plugin. What is strange is that I now cannot see any of the nice decorations and the all forms look like the plain standard scaffold. Any pointers?
November 25th, 2007 at 11:18 PM @Navin, sounds like the css isn't being included have you add the ajax_scaffold_includes call to your layout?
November 25th, 2007 at 11:18 PM hi Scott, I am using ajax Scaffold 3.2.4, and Rails 1.2.2 , Protoype 1.5.0. I tried to change prototype code and remove rico (code above), but Create, Edit, Sort, Delete ... buttons still don't work. Can you tell me if you have any others solutions ? Thanks Toch
November 25th, 2007 at 11:18 PM With Firebug, I got : POST http://127.0.0.1:3002/salaries/new?sort_direction=asc&scaffold_id=salarie&page=1 (216ms) Error in Protoype.Js Line 866 this.transport.send(body); Any ideas ?
November 25th, 2007 at 11:18 PM Hi Toch, 3.2.4 should just work with 1.2.2, ,it includes a better fix than those shown above. Cheers Scott
November 25th, 2007 at 11:18 PM Thanks for your answer, I have already tried without changing code, but Edit and New buttons still don't work. In development.log, I got : DEPRECATION WARNING: @flash is deprecated! Call flash.[] instead of @flash.[]. Args: [:error] See http://www.rubyonrails.org/deprecation for details. (called from _run_rhtml_47app47views47ajax_scaffold47_messages46rhtml at script/../config/../app/views/ajax_scaffold/_messages.rhtml:2) Rendered ajax_scaffold/_messages (0.00102) Rendered ajax_scaffold/_form_messages (0.00157) I got those problems with AjaxScaffold when I upgraded Rails 1.1.6 to 1.2.2 Toch
November 25th, 2007 at 11:18 PM I created a new project, and now AjaxScaffold 3.2.4 works with Rails 1.2.2 . When you update a project developed in 1.1.6 to 1.2.2 , you get some bugs (dunno why) with AjaxScaffold ). Toch
November 25th, 2007 at 11:18 PM Hi Toch, did you remember to update your javascripts after updating rails: rake rails:update:javascripts? I guess from the errors you saw you didn't. Glad you got it working anyway. Cheers Scott
November 25th, 2007 at 11:18 PM Hello Scott ! Indeed, I didn't update may javascripts after updating rails. I didn't know <<rake>> command. Thanks for information. Toch