Rails jquery-fileupload gem - couldn't find fi

2019-05-15 21:52发布

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.

6条回答
Rolldiameter
2楼-- · 2019-05-15 22:13

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

查看更多
放荡不羁爱自由
3楼-- · 2019-05-15 22:29

Remove it from assets group, and it'll work fine.

查看更多
做自己的国王
4楼-- · 2019-05-15 22:34

I think you wanna add the following line to application.js

//= require jquery-fileupload 
查看更多
闹够了就滚
5楼-- · 2019-05-15 22:35

I found a "solution" - restarting rails server did the trick.

查看更多
Summer. ? 凉城
6楼-- · 2019-05-15 22:35

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

查看更多
趁早两清
7楼-- · 2019-05-15 22:36

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

查看更多
登录 后发表回答