Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deployment rails app. JQuery-UI error

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'
like image 892
GeorgesLeYeti Avatar asked May 29 '13 17:05

GeorgesLeYeti


2 Answers

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'
like image 73
GSnyder Avatar answered Oct 14 '22 17:10

GSnyder


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

like image 28
Deej Avatar answered Oct 14 '22 18:10

Deej