Skip to content

AjaxScaffold and Rails 1.2.1

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…..

13 Comments

  1. 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.

    Monday, January 22, 2007 at 10:08 am | Permalink
  2. Scott Rutherford wrote:

    Hi Ariejan, there is now a release that fixes all this for you: 3.2.3. Cheers
    Scott.

    Monday, January 22, 2007 at 10:08 am | Permalink
  3. Christoffer wrote:

    I’m still having this problem after trying these fixes? What should I do next?

    Monday, January 22, 2007 at 10:08 am | Permalink
  4. Christoffer wrote:

    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…

    Monday, January 22, 2007 at 10:08 am | Permalink
  5. Navin Samuel wrote:

    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?

    Monday, January 22, 2007 at 10:08 am | Permalink
  6. Scott Rutherford wrote:

    @Navin, sounds like the css isn’t being included have you add the ajax_scaffold_includes call to your layout?

    Monday, January 22, 2007 at 10:08 am | Permalink
  7. Toch wrote:

    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

    Monday, January 22, 2007 at 10:08 am | Permalink
  8. Toch wrote:

    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 ?

    Monday, January 22, 2007 at 10:08 am | Permalink
  9. Scott Rutherford wrote:

    Hi Toch,

    3.2.4 should just work with 1.2.2, ,it includes a better fix than those shown above.

    Cheers
    Scott

    Monday, January 22, 2007 at 10:08 am | Permalink
  10. Toch wrote:

    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

    Monday, January 22, 2007 at 10:08 am | Permalink
  11. Toch wrote:

    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

    Monday, January 22, 2007 at 10:08 am | Permalink
  12. Scott Rutherford wrote:

    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

    Monday, January 22, 2007 at 10:08 am | Permalink
  13. Toch wrote:

    Hello Scott !
    Indeed, I didn’t update may javascripts after updating rails. I didn’t know <<rake rails:update:javascripts>> command.

    Thanks for information.
    Toch

    Monday, January 22, 2007 at 10:08 am | Permalink