I got the following errors,
When I opened the Chrome javascript console,then look insight it.
application.js?body=1:1249
It is just a group of compressed js code
And I've open the in the development.rb
# Expands the lines which load the assets
config.assets.debug = true
I can not grep the any piece of the javascript source code in my Rails app.
So I don't know where does it come from ?
How can I fix the unknown error quickly in Rails ?
Thanks
Uncaught Error: Graph container element not found application.js?body=1:1249
GET http://www.superfish.com/ws/sf_main.jsp?dlsource=vbqxugf&userId=Ei9nuSYzM8NCWiFeoMKLn6&CTID=addtofeedly net::ERR_BLOCKED_BY_CLIENT
application.js
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require bootstrap
//= require tinymce-jquery
//= require raphael
//= require morris
//= require_tree .
Make sure sure you are running rails in development mode and
config.assets.compress = false
is set in development.rb
If you do not manage to get the uncompressed version you the another option:
Compressed files can be made "pretty" in Chrome if you click on the {} symbol.
https://developer.chrome.com/devtools/docs/javascript-debugging#pretty-print
Related
I am building an app on my local machine. When I precompile and run it in production mode, the compiled javascript stops working. Specifically, I have javascript in one coffeescript file and application.js, both in the assets folder. All other javascript (i.e. jquery in ajax forms, etc) continues to work, which is why I think it must have to do with compilation.
Here is my application.js file:
//= require jquery
//= require jquery_ujs
//= require jquery-ui/autocomplete
//= require jquery-ui/dialog
//= require autocomplete-rails
//= require dresssed
//= require raphael
//= require morris
//= require best_in_place
//= require_tree .
$('.label-stock-health').popover({ html : true});
$(document).keypress(function(e) {
if ($('.search-bar').length){
if($(".search-bar").is(":visible")) {
} else {
$(".search-bar").show();
$("#q_name_cont").focus();
}
}
});
$("#spinner").hide();
$(document).ajaxStart(function() {
$("#spinner").fadeIn('slow');
}).ajaxStop(function() {
$("#spinner").hide();
});
$(document).ready(function() {
$(".show-search").click(function(){
if ($('.search-bar').length){
$(".search-bar").toggle();
}
});
$(".best_in_place").best_in_place();
});
This functionality still works in development mode. Additionally, if I hard code the javascript into my layout template, it will work. But without the hardcoding, it does not.
Any advice on what might be the culprit? If not , what is the best way to go about debugging this?
UPDATE #1
The only two errors I am seeing in the Javascript console of Chrome developer tools are posted below. They also show on my localhost development instance, where my javascript functionality is working in full.
Uncaught Google Maps API is required. Please register the following
JavaScript library
http://maps.google.com/maps/api/js?sensor=true.(anonymous function) #
application-6ab26aa5fc5d647a3b5543af7c9838a6.js:9t.(anonymous
function) #
application-6ab26aa5fc5d647a3b5543af7c9838a6.js:9(anonymous function)
# application-6ab26aa5fc5d647a3b5543af7c9838a6.js:9 variants:565 GET
http://www.example.com/bootstrap/glyphicons-halflings-regular.woff2
404 (Not Found)
I did wrote to you in upwork.com how ever here it is... If it is working in local host but when uploaded online stops working than it is permissions problem. I have encounter same problems in godady and blue host. Try playing with permissions. For (on blue host) worked permissions to be set at 5 5 4. or 5 5 5 I did not remember correctly. How ever delete all and reupload with new permissions once you figure out what they should be.
The culprit here is the popover line, you will need to include the popover plugin if you want to use it. Comment it out and deploy your code, it will start working again.
I've just sent you a message on upwork as well, but you should check if removing turbolinks from your application.js files resolves the issue:
//= require jquery
//= require jquery_ujs
//= require turbolinks ** remove this line as turbolinks interferes with javascript occasionally.
//= require_tree .
Please include another file name custom.js and updated
$(document).ajaxStart(function() {
$("#spinner").fadeIn('slow');
});
$(document).ajaxStop(function() {
$("#spinner").hide();
});
I have a small JS file (common.js) containing one function. I have the following lines in application.js:
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require jquery.readyselector
//= require common
//= require_tree .
When I store it in
app/assets/javascripts
or
vendor/assets/javascripts
the file is loaded properly, but when I move it to
lib/assets/javascripts
it stops working and I get the error:
Sprockets::FileNotFound
couldn't find file 'common'
(in C:/Sites/rails_studio/beatjoe/app/assets/javascripts/application.js:21)
All this eventhough my Rails.application.config.assets.paths is:
- C:/Sites/rails_studio/myappname/app/assets/images
- C:/Sites/rails_studio/myappname/app/assets/javascripts
- C:/Sites/rails_studio/myappname/app/assets/stylesheets
- C:/Sites/rails_studio/myappname/lib/assets/javascripts
- C:/Sites/rails_studio/myappname/vendor/assets/fonts
- C:/Sites/rails_studio/myappname/vendor/assets/images
- C:/Sites/rails_studio/myappname/vendor/assets/javascripts
- C:/Sites/rails_studio/myappname/vendor/assets/stylesheets
- C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/turbolinks-2.3.0/lib/assets/javascripts
- C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/jquery-rails-3.1.2/vendor/assets/javascripts
- C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/coffee-rails-4.0.1/lib/assets/javascripts
According to the documentation, not only should common.js be included due to
//= require common
but also be caught by
//= require_tree .
What am I missing?
I was able to reproduce the Sprockets::FileNotFound error by creating the lib/assets/javascript directory while the local server was running. It appears you need to restart the server to pick up directory changes.
Now that your server has since been restarted, you should be able to add files to the directory without restarting your server.
I am trying to get rangeslider.js working in Ruby on Rails. I have used their GitHub page as a reference, but couldn't find any help for Rails.
http://andreruffert.github.io/rangeslider.js/
Application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require rangeslider.js
//= require rangeslider.min.js
//= require_tree .
I came across the following error message
Sprockets::FileNotFound
(in C:/Users/rmatthews/Documents/repos/pcbuilder/app/assets/javascripts/application.js:17)
Line 17, was //= require rangeslider.min.js
The files are located on my computer, but in my /downloads/rangeslider.js-0.3.7 directory
My guess is that Rails does not search that directory.
Do I need to place them somewhere else, like /vendor/assets?
I've been following this as a Reference, but couldn't find much
http://guides.rubyonrails.org/asset_pipeline.html#how-to-use-the-asset-pipeline
I've seen a couple of similar questions, but since they were discussing jquery, they didn't seem to be of much help.
Rails does not search random directories that exist outside of your application. You will need to place this file at vendor/assets/rangeslider.js.
Then require it by:
//= require rangeslider
I am trying hard to have one of my javascript file load/work with a Rails4 app.
The file is users.js.coffee . This is a catch all javascript file that I want loaded for all pages (not necessarily just for users controller)
If I try to load by localhost:3000/assets/users.js I can see the compiled JS file. However using cmd+o on chrome doesnt load the file and also the events are not fired so I know its not working(and loading)
Also tried running bundle exec rake assets:clean assets:precompile
I do not see any 500 or 400 or js errors in console. The simplest of users.js.coffee doesnt work as well
$(document).ready ->
alert('hello')
Some configs:
applcations.js
//= require jquery
//= require jquery_ujs
//= require js-routes
//= require bootstrap-slider
//= require users
//= require_tree .
development.rb
config.assets.initialize_on_precompile = false
config.serve_static_assets = false
production.rb
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = true
# Compress JavaScripts and CSS
config.assets.compress = true
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true
config.assets.debug=true
Also the users.js.coffee was working fine before I started playing around with getting bootstrap using bootstrap-sass etc (on an tangent,eventually ended up loading bootstrap from hosted CDNs in application.haml, not sure if it should interfere with how js files are loaded/works)
Any pointers to debug this is greatly appreciated. Already spent few hours and Asset Pipeline gets me everytime
Thanks
P.S:
I am deploying to heroku (however this fails in both dev and heroku so hopefully fixing in dev should be enough)
Update application.js content by moving //= require users after all other libraries that your application's javascripts depend on but before the require_tree .:
//= require jquery
//= require jquery_ujs
//= require js-routes
//= require bootstrap-slider
//= require users
//= require_tree .
The order of requiring javascripts is important here. If your file is users.js.coffee then you need jQuery for coffeescript so jQuery must be required before users.
my app's working directory looks something along the lines:
app
-assets
-javascripts
- theme
--jquery.min.js
--excanvas.min.js
-- application.js
The application.js previously had require_tree ., however, it loaded excanvas.min.js before jquery.min.js. This brought up a javascript error. I would like to switch the load order. So I updated application.js to:
//= require unicorn/jquery.min
//= require unicorn/excanvas.min
However, this gave me the following error:
Sprockets::FileNotFound in Admin::Home#index
couldn't find file 'unicorn/jquery.min.js'
I was wondering why I can't seem to find jquery.min. Any ideas?
Thanks!
I changed the application.js to:
//= require ./unicorn/jquery.min
//= require ./unicorn/excanvas.min
and it seemed to work.