5

I just deploy my application on a cloud server and then enconter an error:

ActionView::Template::Error (couldn't find file 'jquery-ui'
  (in /home/me/.rvm/gems/ruby-1.9.3-p429/gems/activeadmin-0.6.0/app/assets/javascripts/active_admin/base.js:2)):

I previously deploy the same app on a shared host but i didn't get this error previoulsy. So i guess i miss something in my deployment. Btw in the base.js:

//= require jquery
//= require jquery-ui
//= require jquery_ujs
//= require active_admin/application

And in my app/assets/javascripts/application.js.erb:

//= require Player/soundmanager2-nodebug-jsmin.js
//= require jquery
//= require jquery.ui.all
//= require jquery_ujs
//= require best_in_place
//= require best_in_place.purr
//= require jquery-fileupload
//= require contextMenu/jquery.contextMenu.js
//= require contextMenu/jquery.ui.position.js
//= require_tree .
//= require_tree ./Player

EDIT: In my Gemfile:

# 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'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'
gem 'jquery-fileupload-rails'
gem 'jquery-ui-rails'

2 Answers 2

6

I've been struggling with this same issue...

I believe you're running into a recently-created headbutt between ActiveAdmin and the jquery-rails gem; there's nothing wrong with your configuration per se.

jquery-rails used to include a copy of the JavaScript for JQuery UI (but not the CSS; not sure why). That's what's pulled in by the line

//= require jquery-ui

in ActiveAdmin's base.js file. Recently, jquery-rails dropped its inclusion of the JQuery UI JavaScript, so the line above now points to nothing and causes an asset build error. Installing jquery-ui-rails doesn't help because that gem renames the files so that the proper require line is

//= require jquery.ui.all

probably to avoid conflict with the previous versions of jquery-rails.

Unfortunately, ActiveAdmin can't simply rebase itself on jquery-ui-rails instead of jquery-rails and maintain backwards compatibility with Rails 3.0, at least according to this issue report. So a solution may be a few days in coming.

In the meantime, just request an older version of jquery-rails that still includes the JavaScript for JQuery UI in your Gemfile:

gem 'jquery-rails', '<3.0.0'
Sign up to request clarification or add additional context in comments.

2 Comments

I tried all sorts of things and finally the '<3.0.0' worked. Thanks!
The fact that the file was renamed was my issue. Thanks for this :)
2

Encountered something similar and found that removing gem jquery-ui out of the group :assets block fixed this for me. Furthermore you will notice in the gemfile it says the following:

# Gems used only for assets and not required
# in production environments by default.

So make sure this is not part of the :assets group

Update

I believe your ordering of your application.js should look like this:

//= require jquery
//= require jquery_ujs
//= require_tree .
//
//= require jquery-ui
//= require jquery.ui.all
//= require active_admin/application
//= require Player/soundmanager2-nodebug-jsmin.js
//= require best_in_place
//= require best_in_place.purr
//= require jquery-fileupload
//= require contextMenu/jquery.contextMenu.js
//= require contextMenu/jquery.ui.position.js

Furthermore just to ensure that your setup is correct in your application.rb you should have:

Application.rb

if defined?(Bundler)
  # If you precompile assets before deploying to production, use this line
  Bundler.require(*Rails.groups(:assets => %w(development test)))
  # If you want your assets lazily compiled in production, use this line
  # Bundler.require(:default, :assets, Rails.env)
end

production.rb

  # Disable Rails's static asset server (Apache or nginx will already do this)
  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

When you want to do the following command: bundle exec rake assets:precompile:all RAILS_ENV=production

5 Comments

@GeorgesLeYeti If you look at the error it says (couldn't find file 'jquery-ui' it is looking for jquery-ui. From your previous comment you just mentioned that gem 'jquery-ui-rails'
@GeorgesLeYeti Also the infrastructure jquery files should be called first. The ordering of your required files is important. Further more I dont understand why you have app/assets/javascripts/application.js.erb this does not make no sense to me why did you do this
@GeorgesLeYeti added further to my answer
Ty a lot. I removes the content of base.js file and it works but don't like this idea. I'll go back on my change and test your solution.
@GeorgesLeYeti No worries I wouldn't say remove the content of the base.js file. It is good practice following asset pipeline to require your JS in your application.js which I have set up for you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.