Search code examples
ruby-on-rails-3.1

Why active scaffold form gets broken after assets precompile?


Why active scaffold links(e.g.: Create, Edit, Show, etc.) are not working after assets precompile?


Solution

  • This happened to me as well - very frustrating indeed. With Rails 3.2 and ActiveScaffold, after pre-compiling assets, all AJAX based forms generated by ActiveScaffold stopped working "in-place". Note that the forms still work fine if you load them in the browser directly as "localhost:3000///edit" etc.

    It has to do with the sequence in which javascript was loaded in the application.js file. We had to make sure that jquery_ujs is at the end. After making the change, our application.js looks like:

    //= require jquery
    //= require_tree 
    //= require active_scaffold
    //= require jquery.tipsy.js
    //= require jquery.dcmegamenu.1.3.3.js
    //= require jquery.hoverIntent.minified.js
    //= require jquery_ujs
    

    Then run rake assets:precompile and everything works fine.

    Hope this helps you!