0

I've done this command

bundle exec rake assets:precompile RAILS_ENV=production

Now, loaded jQuery won't be started when page is loaded:( It used to work fine before precompiling...

What could be the possible reason?

assets/javascripts/refresh_count.js

    jQuery(document).ready(function () {
        refreshPartialMail();
    });


    function refreshPartialMail() {
      $.ajax({
        url: "/messages/refresh_part",
        type: "GET",
        dataType: "script",
      });
    }

view

...
<%= javascript_include_tag 'refresh_count' %>
...

generated HTML

<script src="/assets/refresh_count-0cdf67811wb7eavf438be9c8b8cc932bf.js" type="text/javascript"></script>

the content of "/assets/refresh_count-0cdf67811wb7eavf438be9c8b8cc932bf.js"

function refreshPartialMail(){$.ajax({url:"/messages/refresh_part",type:"GET",dataType:"script"})}jQuery(document).ready(function(){refreshPartialMail()});

assets/javascripts/application.js

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery-ui
//= require twitter/bootstrap
//= require jquery_ujs
//= require jquery.ui.datepicker
//= require autocomplete-rails

It's also saying this when executing precompile does this matter???

DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /var/www/html/sampleapp/Rakefile:7)
2
  • 1
    are you using prototype & jQuery both, if so replace $ with jQuery like $.ajax to jQuery.ajax beacuase sometimes it conflicts with prototype Commented Apr 25, 2013 at 4:50
  • @Sali Thanks for reply:) I'm not using prototype Commented Apr 25, 2013 at 8:12

1 Answer 1

3

I am using jquery in my project also and it works fine

on production also

Here is my application.js content

//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require tinymce
//= require_tree .

I think adding //= require_tree . may solve problem pls try it once and reply....

Sign up to request clarification or add additional context in comments.

5 Comments

Hey one quick suggestion if you are using firefox try firebug and check console if any errors or conflicts are there ......
I checked it on FireFox's web console. Before, I could see javascript was being called in background. But now, nothing appears in web console:(
I doubt it because of dependencies of gems or something... I did bundle install --path=vendor/plugins does this matter?
Let me know one thing does app works fine on development mode or after precompiling even on developement mode it doesnt work
I've found it!!! I was right I replaced whole app with the one before I've done bundle install --path=vendor/plugins. Then I did bundle exec rake assets:precompile RAILS_ENV=production. Now jQuery works fine!! This is so weird!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.