I'm trying to follow the Railscasts episode on jQuery-FileUpload. I've added
gem 'jquery-fileupload-rails'
to the assets group of the Gemfile, and also added the
//= require jquery-fileupload/basic
line to the application.js file in the asset directory. When I try to bring up the website, however, the following error is shown:
couldn't find file 'jquery-fileupload'
(in root/app/assets/javascripts/application.js:15)
Any help would be greatly appreciated.
I found a "solution" - restarting rails server did the trick.
Remove it from assets group, and it'll work fine.
I have fix this by :
add
gem 'therubyracer'
gem 'execjs'
to your Gemfile.
and run bundle install
and
rake assets:precompile --trace RAILS_ENV=production
That's really weird, I just tried with a Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.12'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem "jquery-fileupload-rails"
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
and on application.js
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require jquery-fileupload/basic
and worked great, did you run bundle ? I know its a stupid question but it may be
I think you wanna add the following line to application.js
//= require jquery-fileupload
I ran into something similar lately. What worked for me was to load the gem directly from git
gem 'jquery-fileupload-rails', git: 'git://github.com/ollnixon/jquery-fileupload-rails.git'
And then to load the the needed ui styles
*= require jquery.fileupload-ui
Works flawlessly now
Related
I am watching the old One Month Ruby on Rails lectures without being enrolled in the course and encountered this problem. I have searched through about 20 stackoverflow and github tutorials and can't find the problem, any help is greatly appreciated. (This is my first time posting here so if I am doing something wrong or need to include more information let me know).
Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.6'
gem 'jquery-rails'
# Use sqlite3 as the database for Active Record
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
group :assets do
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'
end
Styles.css.scss :
#import "bootstrap";
application.js :
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require_tree .
According to the Question its clearly stated that you need to restart your server whenever a gem is installed or updated, if you upgrade ruby, or if you change some logic that runs during boot time (like config/boot.rb or config/database.yml). Otherwise it's generally ok not to, even if you edit/add models/controllers.
Remove group "assets" from Gemfile. It is obsolete in Rails 4.
Rails 4.0 removed the assets group from Gemfile. You'd need to remove
that line from your Gemfile when upgrading.
See Ruby on Rails Guides
you use gem bootstrap-sass than in your application.js use
//= require bootstrap-sprockets
and in your application.css use
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
#import "bootstrap-sprockets";
#import "bootstrap";
I'm attempting to implement bootstrap into my app and I keep getting a couple errors that I've never received when starting apps before. I browsed for an answer and the only answers I keep finding are to remove the assets part of the Gemfile which I don't have and to restart the server which I've done several times with no luck. Below are the errors and my files. Please let me know if something else needs to be provided. Thank you!
Browser Error:
File to import not found or unreadable: bootstrap-sprockets
Rails Server Warnings:
/Users/tucker/.rvm/gems/ruby-2.2.1/gems/bootstrap-sass-3.3.6/lib/bootstrap-sass/version.rb:2: warning: already initialized constant Bootstrap::VERSION
/Users/tucker/.rvm/gems/ruby-2.2.1/gems/bootstrap-4.0.0.alpha3/lib/bootstrap/version.rb:2: warning: previous definition of VERSION was here
/Users/tucker/.rvm/gems/ruby-2.2.1/gems/bootstrap-sass-3.3.6/lib/bootstrap-sass/version.rb:3: warning: already initialized constant Bootstrap::BOOTSTRAP_SHA
/Users/tucker/.rvm/gems/ruby-2.2.1/gems/bootstrap-4.0.0.alpha3/lib/bootstrap/version.rb:3: warning: previous definition of BOOTSTRAP_SHA was here
Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.2.5'
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development do
gem 'sqlite3'
end
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'bootstrap'
gem 'figaro'
gem 'pry'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bootstrap-sass'
group :development, :test do
gem 'byebug'
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'rspec-rails'
gem 'shoulda'
gem 'faker'
gem 'factory_girl_rails'
end
Application.js:
//= require jquery
//= require bootstrap-sprockets
//= require jquery_ujs
//= require turbolinks
//= require_tree .
Application.scss:
...
*= require_tree .
*= require_self
*/
#import "bootstrap-sprockets";
#import "bootstrap";
I see you have gem 'bootstrap' and gem 'bootstrap-sass' in your gemfile. If you delete one of them, run bundle and follow the installation instructions on the respective github site then the sprockets should work. Also mine application.scss file is usually without the require part.
1º) Install the following gems in your Gemfile:
gem 'bootstrap-sass', '~> 3.3.6'
gem 'autoprefixer-rails'
2º) Issue the following command:
mv app/assets/stylesheets/application.css app/assets/stylesheets/application.css.sass
3º) Edit pp/assets/stylesheets/application.css.sass and append the following lines:
#import "bootstrap-sprockets"
#import "bootstrap"
4º) Edit your app/assets/javascripts/application.js file and be sure it has the following lines:
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .
5º) Now run
bundle install
And you are ready! This recipe always works for me and it is in this site.
Hope it helps!
Problem : file to import not found or unreadable bootstrap-sprockets
#import "bootstrap-sprockets";
#import "bootstrap";
...........
solution :
gem 'rails', '5.0.0.1'
gem 'bootstrap-sass', '3.3.6'
do bundle install
then restart your rails server
I am using Ruby -v 2.2.1 and Rails version 4.2.4 with gems haml, simple_form, and bootstrap-sass indicated below. I consistently get the following error:
Sprockets::FileNotFound in Static_page#index
The error also indicates that it could not find my file in javascript/application, more specifically this is what I have app/assets/javascripts/application.js:
//= require bootstrap-sass/assets/javascripts/bootstrap-sprockets
In addition, I have these included as well in application.js:
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .
I also have the following included in my application.css.scss:
#import "bootstrap-sprockets";
#import "bootstrap";
And here are the gem files I am using:
gem 'rails', '4.2.4'
gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'haml', '~> 4.0', '>= 4.0.7'
gem 'simple_form', '~> 3.2', '>= 3.2.1'
gem 'bootstrap-sass', '~> 3.3.6'
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
end
I have already conducted a bundle install and restarted my rails sever several times to try to troubleshoot.
Why does this error keep occurring and might there be some kind of incompatibility with my gems' versions? Thank you.
The error simply states that it cannot find the JS file which has been called in application.js.
According to the docs, you need to have the following in your JS pipeline to get it working:
//= require jquery
//= require bootstrap-sprockets
Referencing bootstrap-sass/assets/javascripts/bootstrap-sprockets seems to violate that pattern (remember, asset_path acts like a PATH env var -- you can reference individual files without the relative path).
For me, this happened after upgrading to rails 7, and was because rails 7 doesn't come with Sprockets.
I fixed by adding sprockets and everything worked:
# Gemfile
gem "sprockets-rails"
More info here
Rails: 4.0.0
Ruby : 1.9.3
I am using jQuery's animate() method in my Rails application.
I can't get it to work.
I've read the documentation at jquery-ui-rails and followed the steps mentioned there, i.e.,
Installed the gem
included it in the Gemfile - gem 'jquery-ui-rails'
bundle install
Added the //= require jquery.ui.all in my application.js file
Yet I get an Sprockets::FileNotFound error.
Showing /Users/anil20787/workspace/railsdir/depot/app/views/layouts/application.html.erb where line #9 raised:
couldn't find file 'jquery.ui.all'
(in /Users/anil20787/workspace/railsdir/depot/app/assets/javascripts/application.js:14)
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'jquery-ui-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
I did also look up this post with a problem similar to mine, but it is pointing to the documentation, whose steps I have already followed. Not sure where I have made a mistake.
Any help is appreciated. Thanks
According to this the order of the includes is important. Can you post your include file?
Put //= require jquery.ui.all right after //= require jquery so it will look like this
//= require jquery
//= require jquery.ui.all
//= require jquery_ujs
//= require underscore
//= require backbone
//= require svitla_test
//= require_tree .
Restarting my Rails server did it for me.
If anyone still struggle with this I added gem 'rails-asset-jqueryui' then run bundle install and after it, restart server... then the file should be found, of course you also need to add
//= require jquery.ui.all in application.js file
and
*= require jquery.ui.all in applications.css file
I'm using twitter bootstrap in my Rails application. It works well in development mode but does not in production. Here is the Gemfile
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails'
gem 'jquery-rails'
gem 'haml-rails'
gem 'devise'
gem 'bcrypt-ruby'
gem 'curb'
gem 'nokogiri'
gem 'pg'
group :assets do
gem 'sass-rails'
gem 'twitter-bootstrap-rails'
gem 'uglifier'
end
When I run it as rails s -e production it gives me the error of
ActionView::Template::Error (couldn't find file 'twitter/bootstrap'
(in /home/alex/Documents/ruby_projects/p1/app/assets/javascripts/application.js:15)):
Application.js
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require_tree .
production.rb
config.serve_static_assets = false
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true
# Generate digests for assets URLs
config.assets.digest = true
Somebody suggested me to remove gem 'twitter-bootstrap-rails' which I cannot do because I use it or move it outside of group assets which didn't help me either: the application well except the fact that twitter bootstrap files (js and css) weren't loaded at all.
How do I fix it?
UPDATE:
If I use use //= require bootstrap instead of //= require twitter/bootstrap then it gives me cannot load such file -- less (in home/alex/Documents/ruby_projects/pr1/app/assets/stylesheets/bootstrap_and_overrides.css.less) despite the fact that the file exists.
And if I rename css.less to css, then I get the next error couldn't find file 'bootstrap_and_overrides' (in /home/alex/Documents/ruby_projects/pr1/app/assets/javascripts/application.js:15)
Restarting the server worked for me.
I solved this issue by using following steps:
Move twitter-bootstrap-rails gem from outside of :assets in gemfile
Update twitter-bootstrap-rails gem version 2.2.6 or
just paste below line in your gemfile.
gem 'twitter-bootstrap-rails', :git => 'git://github.com/seyhunak/twitter-bootstrap-rails.git'
(or)
if twitter-bootstrap-rails 2.2.6 is not working then
Use twitter-bootstrap-rails gem latest version.
Just use //= require bootstrap instead of //= require twitter/bootstrap.
Requiring Bootstrap LESS (bootstrap_and_overrides.css.less) in your application.css is meaningless here, because the pipeline comes already with "require_tree ." which automatically includes everything inside the folders of the asset pipeline.
so, I suggest you to do some changes in your Gemfile.
Move the following gems from outside of :assets in Gemfile.
do this
gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"
instead of this
group :assets do
gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"
end
Follwing steps worked for me:
Move twitter-bootstrap-rails gem from outside of :assets in gemfile
replace the twitter bootstrap gem by this (gem "twitter-bootstrap-rails", '~> 2.2.6') in gemfile
bundle update
restart server and test