I try to install react-router and material-ui on my rails 4 app but I get Sprockets::FileNotFound error for react-router and material-ui. I follow instructions from rails-assets.org.
My Gemfile:
source 'https://rails-assets.org' do
gem 'rails-assets-classnames'
gem 'rails-assets-lodash'
gem 'rails-assets-react-router'
gem 'rails-assets-material-ui'
end
application.js
//= require jquery
//= require lodash
//= require jquery_ujs
//= require react
//= require classnames
//= require react_ujs
//= require react-router
//= require turbolinks
//= require_tree .
And after bundle I got this notification on some gems This component doesn't define main assets in bower.json.. Thank you for your time and I hope we work this out.
UPD 1:
I found kind of a solution on stackoverflow but I would like to stick to rails-assets.org way if possible.
ruby '2.2.0'
rails '4.2.3'
Might be easy to forget, but have you restarted your (running) rails server?
Started to use rails-assets yesterday as well and it showed me the exact same problem (Sprockets::FileNotFound).
I restarted the running server in the console and the problem was solved.
Rails 4.2.5
/ Ruby 2.3.
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.
So, I was struggling at the last few hours about getting my bootstrap navbar to work in my rails 5.1.3 app. No success. I found a console error saying
Uncaught Error: Bootstrap dropdown require Popper.js
I was aware that bootstrap was dropping tether in favour of popper.js. I added it to the Gemfile
gem 'popper_js', '~> 1.11', '>= 1.11.1'
and it did nothing. Added to the application.js like this
//= require popper
and still nothing. After a while, I bumped into Joshua Colvin's answer about popper.js in Angular. After moving the popper line up in the code, like this
//= require popper
//= require turbolinks
//= require bootstrap
And got it to work. I wanted to share this to the community because it is a pretty recent topic and was very hard to find this fix. Hope this helps a lot of coders ;)
Just add require popper before turbolinks and bootstrap like you said in the question
//= require popper
//= require turbolinks
//= require bootstrap
I'm following this tutorial: https://thinkster.io/angulartutorial/angular-rails/ and everything went well till the part where I had to arrange my angular code with folders in the rails assets pipeline javascripts and use the gem 'angular-rails-template' (https://github.com/pitr/angular-rails-templates) to reach them.
I've installed the gem through the Gemfile and I'm getting a "couldn't find file 'angular-rails-templates'" error even though I've required the file in the application.js:
//= require angular
//= require angular-rails-templates
//= require angular-ui-router
//= require_tree .
Any suggestions?
Apperantly I was sure that I restarted the server, which I didn't. If anyone encouter this problem try the old fashioned solution to fix it.
For some reason my bootstrap broke after I precompiled my code. This started because I couldn't push to heroku because of a precompile error.
So here are the contents of my application.js file:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap3
//= require bootstrap
//= require bootstrap/dropdown
//= require_tree .
Maybe the order is wrong? I just added .../dropdown hoping it would help, but it did not. I just realized I can actually remove both bootstrap lines without affecting my resulting site.
For my gems, I have:
gem 'bootstrap-sass', "~>3.0.3.0"
...
gem 'bootstrap-will_paginate', '0.0.6'
Here is a link to my other question, which is similar but less focused: Ruby on Rails: Ran rake assets:precompile and now both local and heroku deployment don't include bootstrap
Any help would be greatly appreciated. I'm getting pretty frustrated, it's been several days of failed action.
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.