//= require jquery
How is the jquery library being loaded in with this?
I do not have jquery files anywhere in the project to be loaded.
What magical place are they loaded from?
Same goes for //= require bootstrap-sprockets I put this line in so that bootstrap was loaded correctly.
I have the gem but what magic is done here?
those files got loaded because you have the gem 'jquery-rails' and the gem 'bootstrap-sass', '~> 3.3.6'
they hold the js, css, and images files in the assets directory inside there gem
what the Rails Asset Pipeline does is look at the assets and vendor directories to compile the files
I hope that this explanation works
you can see the assets for bootstrap-sass and jQuery here
Related
We're using Rails Assets in our project and we're in the process of updating Ruby from 2.3.7 to 2.4.7, following this guide. I think I've resolved all the gems issues, but when I'm trying to run rspec or navigate to any admin page, I'm greeted with this error:
couldn't find file 'fullcalendar'
This is one of the Rails Assets mentioned above, and I'm not sure why this is happening.
My gemfile:
source 'https://rails-assets.org' do
gem 'rails-assets-jquery'
gem 'rails-assets-jquery-ujs'
gem 'rails-assets-jquery-ui'
gem 'rails-assets-js-cookie'
gem 'rails-assets-lodash'
gem 'rails-assets-highcharts'
# gem 'rails-assets-quill'
gem 'rails-assets-select2'
gem 'rails-assets-select2-bootstrap-css'
gem 'rails-assets-slick.js'
gem 'rails-assets-picturefill'
gem 'rails-assets-scrollmagic'
gem 'rails-assets-gsap'
gem 'rails-assets-fullcalendar'
gem 'rails-assets-moment'
gem 'rails-assets-jstzdetect'
gem 'rails-assets-blueimp-file-upload'
gem 'rails-assets-air-datepicker'
end
/app/views/layouts/admin.haml:
= javascript_include_tag 'admin'
/app/assets/javascripts/admin.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 any plugin's vendor/assets/javascripts directory 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
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery-ujs
//= require jquery-ui/jquery-ui
//= require lodash
//= require bootstrap
//= require moment
//= require quill
//= require fullcalendar
//= require select2
//= require jstzdetect
//= require cocoon
//= require blueimp-file-upload/jquery.iframe-transport.js
//= require blueimp-file-upload/vendor/jquery.ui.widget.js
//= require blueimp-file-upload/jquery.fileupload.js
//= require_tree ./admin
What have me scratching my head is that the assets above fullcalendar are loading fine, but this one throws an error.
This app is running on Rails 4.2.7.1 and ruby 2.3.7. I'm trying to update Ruby version to ruby 2.4.7.
Try replacing require fullcalendar with
require fullcalendar/core/main.js
require fullcalendar/daygrid/main.js
Just a guess based on the doc
Alternatively, just remove it from assets and put the files directly in vendor folder; or use this gem.
I followed stack overfolw's answer
to add adminlte in my rails app
it also says to add
//= require adminlte
in application.js
it works fine on local system but now when I am trying to deploy to digital ocean droplet it gives error
Sprockets::FileNotFound: couldn't find file 'adminlte' with type 'application/javascript'
My gemfile(I removed all gems except relavent) to clear the adminlte issue
source 'https://rubygems.org'
gem 'bundler', '>= 1.8.4'
gem 'pnotify-rails'
source 'https://rails-assets.org' do
gem 'rails-assets-adminlte', '2.3.3'
end
end
I normal cases we write
source 'https://rubygems.org'
gem 'pnotify-rail'
and in application.js
//= require pnotify
and don't include any file like pnotify.js manully
But in this case I instead used
source 'https://rails-assets.org' do
gem 'rails-assets-adminlte', '2.3.3'
end
and for this
//= require adminlte causing issue
From What I understand, you do not have a file named adminlte in your javascript folder.
Your app/assets/javascripts/ must have all the files that you want to require in your application.js
So if you have required adminlte, you must also have a file with the same name in your javascripts folder.
I see that you are using a theme, you might want to consider copying all the javascript and css files to the respective folders. If you have a folder to require, you could use // require_tree ./adminlte which requires all the files in that folder.
I hope this helps :)
I had the same problem, having to import adminlte on some servers and AdminLTE on others.
Just use rails-assets-admin-lte instead of rails-assets-adminlte (they're based on the same code) and import admin-lte instead of adminlte in your CSS and JS application files.
I download bootstrap and put bootstrap.css and bootstrap.js into my_app/vendor/assets/stylesheets and my_app/vendor/assets/javascripts respectively and also edit these files as follow:
app/assets/javascripts/application.js
//= require bootstrap
app/assets/stylesheets/application.css
*= require bootstrap
bootstrap.css is loaded properly but having problem to load bootstrap.js.
And now you have a problem with loading the icons. I prefer to use the bootstrap-sass gem, where bootstrap is completely prepared for the asset pipeline, and sass, so I can even extend my own sass files with it.
That way also the glyphs are loaded correctly. But I prefer font-awesome for my glyphs, instead.
So in my Gemfile I write:
group :assets do
gem 'bootstrap-sass'
gem 'font-awesome-rails'
end
Try adding bootstrap.js to
app/assets/javascripts/bootstrap.js
I am in the process of upgrading an old app to the asset pipline but after following the ryan bates tutorial on upgrading to 3.1 I am still not able to take advantage of the pipline. In order to rule out my upgrade process I created a fresh rails app and attempted some coffee scripting and adding other files to the /assets/javascripts folder, however any additional files besides the application.js do not seem to be rendered.
This is my application.js file:
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
alert("this displays fine");
And the additional dogs.js.coffee file:
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
alert "cant see this!"
It seems to be a sprockets issue but I really cant find anyone with the same problem, or info on when additional javascript files within the assets folder are not included in the application.js via the require_tree .
Here is my gem file:
gem 'rails', '3.1.1'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.1.4'
gem 'coffee-rails', '~> 3.1.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :test do
# Pretty printed test output
gem 'turn', :require => false
end
my ruby version is 2.0.0p195
thanks for any help!
G
It seems the ruby version was my problem, I downgraded to ruby 1.9.3, then reinstalled gems and it works now!
I just installed the rails-backbone gem and then rails g backbone:install.
I see a list of javascript references to backbone on application.js but it does not copy them to the project and I'm not sure if this is normal.
//= require backbone
//= require backbone_rails_sync
//= require backbone_datalink
//= require backbone/myapp
If this is normal, where is it possible to find backbone_rails_sync and backbone_datalink. I'm afraid that by simple searching will maybe not find the same version tested for this gem?
These files are inside the gem and served through Rails Asset Pipeline.
You could find them in the gem souce.