rails active admin deployment : couldn't find file 'jquery-ui' - ruby-on-rails

when trying to deploy with capistrano, when capistrano use command
bundle exec rake
RAILS_ENV=production
RAILS_GROUPS=assets
assets:precompile
I have this error
couldn't find file 'jquery-ui'
(in /home/umbrosus/.rvm/gems/ruby-1.9.3-p392#gancxadebebi/gems/activeadmin-0.5.1/app/assets/javascripts/active_admin/base.js:2)
Before it was working well, but I tried to update to 0.6 and then I started to have this error. I came back to 0.5.1 and the error is still there. Do I do something bad ?
thanks

The "jquery-rails" gem recently removed jQuery UI.
https://github.com/rails/jquery-rails/commit/2fdcdb2633cbc6426d412c050200fc31d14b9a3b
They recommend using the jquery-ui-rails gem.
There is an active pull request (as of this writing) to add that gem as a dependency. However, the developers of ActiveAdmin have stated that they are "locking it down until we officially drop support for Rails 3.0". The version they are locked to is jquery-rails < 3.0.0.
In the meantime, just modify your Gemfile:
gem "jquery-ui-rails" Not recommended, see #Kevin's comment below
Or you can downgrade your version of jquery-rails:
gem "jquery-rails", "< 3.0.0"
Or you can pull from their Github master branch. They have applied a temporary fix.
gem "activeadmin", github: "gregbell/active_admin"

Well, there is no need to downgrade jquery-rails to 2.3.0 or specify a GitHub branch. Just use jquery-ui-rails. To workaround the file name differences:
Simply create app/assets/javascripts/jquery-ui.js
//= require jquery.ui.all
Create app/assets/stylesheets/jquery-ui.css
/*
*= require jquery.ui.all
*/
These load the correct files to satisfy ActiveAdmin

Though the Pull request has been merged into AA by now, you will still have this problem if you work with the latest release of AA. I don't like to force JQuery-rails down to version 2.3.0 so here's an alternative solution to the problem:
In the active_admin.js file replace
//= require active_admin/base
with
//= require jquery
//= require jquery_ujs
//= require jquery.ui.core
//= require jquery.ui.widget
//= require jquery.ui.datepicker
//= require active_admin/application
kudos to Fred for providing that solution here.

Downgrading "jquery-rails" to "2.3.0" fixed this issue for me as well.

In my case, the jquery issue was due to a gem I was using. I wasn't using jquery directly, so adding app/assets/js/jquery-ui.js to my project didn't help.
Adding gem "jquery-rails", "< 3.0.0" to my gemfile fixed it, but I got an issue with turbolinks immediately after that, which is easy enough to fix...
My final gemfile:
# Temporary fix for jquery issue
gem "jquery-rails", "< 3.0.0"
gem 'turbolinks'
... easy peasy

I know this is already solved. But I want to give one more solution to this that worked for me.
I am running Rails 4.0.8 when having this issue.
I simply remove explicit version number for jquery-rails gem jquery-ui-rails gem.
Mine looks like this essentially:
# js
gem 'jquery-ui-rails'
gem 'jquery-rails'
# rails admin
gem 'rails_admin'
Gemfile.lock kinda figured out the correct version for all three gems automatically.

Related

Rails 4. Gem creating. Include rubyzip gem

I'm creating my own gem(mountable plugin), and I need to include an older version of rubyzip gem. The reason for using the old version is that I have some code templates written in Rails 3. In the gemfile I include the old version as follows:
gem 'rubyzip', "~> 0.9.9"
It installs successfully. In the lib file where I wrote my gem-module I've added:
require 'devise' # work nice.. haven't any error.
require 'zip/zip' # give me error that it is not found
If I try require zip doesn't work either. If I don't require the gem in my lib file, the error disappeared but in the gem's controller I don't have access to Zip constant anymore.

Sass::SyntaxError: File to import not found or unreadable: bootstrap-sprockets

I am suddenly getting this error in development and in production on deployment.
custom.css.scss
#import "bootstrap-sprockets";
#import "bootstrap";
error (in production)
rake aborted!
Sass::SyntaxError: File to import not found or unreadable: bootstrap-sprockets.
Load paths:
/srv/www/myapp/releases/20141001060418/app/assets/images
/srv/www/myapp/releases/20141001060418/app/assets/javascripts
/srv/www/myapp/releases/20141001060418/app/assets/stylesheets
/srv/www/myapp/releases/20141001060418/vendor/assets/javascripts
/srv/www/myapp/releases/20141001060418/vendor/assets/stylesheets
After making changes to Gemfile, do not forget to restart the server with rails s
Restarting the rails server worked like a charm! :D
I solved this issue by upgrading bootstrap-sass
gem 'bootstrap-sass', '3.2.0.2'
Please restart you rails server after every changes in Gemfile
rails server
For the Sass version of Bootstrap 5 in versions of rails before 6
use
gem `bootstrap`
For Sass versions of Bootstrap 3 and 2 Make sure you don't have
gem 'bootstrap' # Remove this line
gem 'bootstrap-sass'
It should just be
gem 'bootstrap-sass'
I solved it in following steps:
List item
copying the "bootstrap.css" in my "app/assets/stylesheets/ (it was missing)
gem install autoprefixer-rails (also modify Gemfile)
gem install sprockets (also modify Gemfile)
bundle install
RESTART server (not just refreshing page)
This is how I solved the issue.
Go to Bootstrap for Sass Github page and follow the instructions:
Add the following to the Gemfile
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'
Run the command
bundle install
Start/restart the server
rails s
Also, make sure the file has .scss extension (or .sass for Sass syntax). If you have just generated a new Rails app, it may come with a .css file instead. If this file exists, it will be served instead of Sass, so rename it.
Then, remove all the *= require_self and *= require_tree . statements from the sass file. Instead, use #import to import Sass files.
I have observed the same behaviour. In my case i have removed the version of the gem 'bootstap-sass' and it worked. There might be compatibility issue with the gem version which was causing the problem.
Gem file
gem 'bootstrap-sass'
After making changes in the gem file perform following commands:
bundle install
If the server is already running then stop it by "CTRL+C" and start the server again
rails s
In your Gemfile you need to add the bootstrap-sass gem, and ensure that the sass-rails gem is present - it is added to new Rails applications by default.
gem 'bootstrap-sass', '3.3.7'
gem 'sass-rails', '5.0.6'
gem 'rails', '5.0.0'
bundle install and restart your server to make the files available through the pipeline.
Import Bootstrap styles in app/assets/stylesheets/application.scss:
// "bootstrap-sprockets" must be imported before "bootstrap" and "bootstrap/variables"
#import "bootstrap-sprockets";
#import "bootstrap";
bootstrap-sprockets must be imported before bootstrap for the icon fonts to work.
Make sure the file has .scss extension (or .sass for Sass syntax). If you have just generated a new Rails app, it may come with a .css file instead. If this file exists, it will be served instead of Sass, so rename it:
$ mv app/assets/stylesheets/application.css TO:
app/assets/stylesheets/application.scss
Then, remove all the *= require_self and *= require_tree . statements from the sass file. Instead, use #import to import Sass files.
e.g
*= require_tree .
*= require_self
To:
#import require_tree .
#import require_self
Do not use *= require in Sass or your other stylesheets will not be able to access the Bootstrap mixins or variables.
Bootstrap JavaScript depends on jQuery. If you're using Rails 5.1+, add the jquery-rails gem to your Gemfile:
gem 'jquery-rails'
$ bundle install
Require Bootstrap Javascripts in
app/assets/javascripts/application.js:
//= require jquery
//= require bootstrap-sprockets
bootstrap-sprockets and bootstrap should not both be included in
application.js
.
bootstrap-sprockets provides individual Bootstrap Javascript files (alert.js or dropdown.js, for example), while bootstrap provides a concatenated file containing all Bootstrap Javascripts.
This will fix the error
Copied #github
This error mostly comes in rails 3.2.x versions.
If you are using rails version 3.2 you have to specify a special version in your gem file like below:
gem 'rails', '3.2.0'
gem 'bootstrap-sass', '3.2.0.2'
It will resolve the problem for rails -v '3.2.0'
put this in gem file
gem 'bootstrap-sass', '~> 3.3.5'
gem 'sass-rails', '>= 3.2'
then run $ bundle install
Restart the server.
If you get this message when running integration tests, make sure that your asset gems are included in the test group.
For example, change:
group :assets do
gem 'sass-rails', '~> 5.0.3'
gem 'uglifier', '>= 1.3.0'
end
To:
group :assets, :test do
gem 'sass-rails', '~> 5.0.3'
gem 'uglifier', '>= 1.3.0'
end
I had the same problem
sass::syntaxerror: file to import not found or unreadable: config/variables.
, I opened a new css file (I called it custom.css) then copied all the css to the file. On application.css I removed the
#import "config/variables" plus all the other #imports
This worked for me, I hope it does work for you too!
make sure you run the following commands after adding this gem to your Gemfile
put this inside your Gemfile
gem "bootstrap-sprockets", "~>3.3"
gem "bootstrap"
now stop your server and run the following:
bundle install
rails server
to restart your server. Refresh your browser and you should see changes reflect immediately.
In production you may have to run this command to precompile your assets:
bundle exec bin/rake assets:precompile
It worked for me. Hope this was helpful.
I was also facing the similar error in development environment:
Error Image
I solved this problem by-
In my gemfile, I added them -
gem 'bootstrap', '~> 4.2.1'
gem 'jquery-rails'
In application.js file,add these -
//= require jquery3
//= require popper
//= require bootstrap-sprockets
In the file with .scss extension, simply add -
#import "bootstrap";
After that, just run bundle install
I encountered that kind of issue.
If you can see lower version of bootstrap-sass than 3.4.1 in "Gemfile.lock",
please upgrade bootstrap-sass gem version.
I was able to fix the issue by changing the (.css) to (.scss). Then in there I just have this..
*= require_tree .
*= require_self
#import "bootstrap";
I also have #import "boostrap" in the application.js file. This is just how it worked for me - not a 100% proper fix - it works though.
I solved My Issue By Removing
gem 'bootstrap'

Rails 4.0.0 Ruby 2.0 gem "rails3-jquery-autocomplete" error

I have encountered the following error when trying to use rails3-jquery-autocomplete:
Initially, I used the latest version of jquery-rails but read that they removed jquery-ui. I have tried downgrading jquery-rails to gem 'jquery-rails', '~> 2.3.0' as recommended in this answer but it did not work. rails active admin deployment : couldn't find file 'jquery-ui'
I also tried restarting my server as suggeste din this answer but did not work either. Asset Pipeline not finding JS file
I would greatly appreciate an explanation as to how to do this in rails 4 using jQuery mobile without the gem as I have no idea and can't find any recent resources.
couldn't find file 'autocomplete-rails'
application.js
//
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require autocomplete-rails
//= require jquery.mobile
//= require turbolinks
//= require_tree .
gemfile
gem 'rails', '4.0.0'
gem 'jquery-rails'
gem 'jquery_mobile_rails'
gem 'jquery-ui-rails'
gem 'rails3-jquery-autocomplete'
You can use this fork https://github.com/francisd/rails3-jquery-autocomplete
In your Gemfile change
gem 'rails3-jquery-autocomplete'
to
gem 'rails3-jquery-autocomplete', git: 'https://github.com/francisd/rails3-jquery-autocomplete'

Rails + Twitter Bootstrap: File to import not found or unreadable: twitter/bootstrap

I am trying to set up Rails app with Twitter Bootstrap (the gem twitter-bootstrap-rails), but I still cannot get over the error
File to import not found or unreadable: twitter/bootstrap.
I found this issue on official Github of the gem, but none of solution from there have worked for me.
Here's my setup:
Gemfile
gem "twitter-bootstrap-rails"
gem 'font-awesome-rails'
gem 'sass-rails', '~> 3.2.3'
group :assets do
#gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
application.css
*= require_self
*= require bootstrap_and_overrides
*= require font-awesome
*= require_tree .
bootstrap_and_overrides.css.sass
#import "twitter/bootstrap";
#import "twitter/bootstrap/bootstrap";
#import "twitter/bootstrap/responsive";
// Font Awesome
#import "fontawesome";
// Glyphicons
#import "twitter/bootstrap/sprites.scss";
What am I missing for correct set up?
Thanks
we had the same problem, i just restarted the rails server and it worked
If you already attempted to shut down the server and restart it, then your problem may be the cached css file that is generated from your sass file. The reason for this may be some varient of live reload which pre-renders several of the scss/haml type files. If that isn't the case then
Read the error message and determine the scss file that is causing the error.
Locate the css file that is generated along the sass file, (i.e. custom.css.scss would generate custom.css).
Delete that file, refresh the page and if this files delete the entire cache found under assets/stylesheets and temp/cache)
For some reason I had to explicitly require the gem to get it working. As suggested in this github issue comment to fix a similar error with bootstrap-sass, it's likely the gem is not loaded automatically. Add require "twitter-bootstrap-rails to e.g config/application.rb file to explicitly require it.
Downgrade the bootstrap-sass gem to v2.3.2 like so:
gem 'bootstrap-sass', '2.3.2'
I had done a bundle upgrade which upgraded the bootstrap gem. This (version downgrade) fixed the problem for me.
The way how I made it work was simply changing the Twitter Bootstrap gem - I used the bootstrap-sass gem, where is set up everything as is described on the Github page and I didn't find any problem with.
Did you try to compile the assets ?
rake assets:precompile
I solved this issue by adding gem 'bootstrap-sass', '3.0.2.1' in my Gemfile (per the recent docs). Make sure you run bundle install afterwards.
I found this response as I was searching for a problem with Michael Hartl's RailsTutorial.org program. I had inadvertently allowed the sprockets gem to be upgraded to 2.12.1 (it was locked in Gemfile.lock). Force downgrading it to 2.11.0 fixed this error and allowed the older bootstrap-sass (2.3.2.0) gem to work correctly.
Back to learning!!
Nothing here worked for me. I gave up, downloaded Bootstrap itself, put the files in my assets, and included them in my CSS. That fixed it.
add following gem in asset group and bundle install
gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"
Try adding
gem 'sass-rails'
to your Gemfile

Rails 3.2 bootstrap-sass not installing

I'm trying to install the bootstrap-sass gem on my Rails 3.2 app, but encounter this error when I call compass install bootstrap :
No such framework: "bootstrap"
I have the gem installed in my Gemfile:
gem 'compass', '~> 0.12.2'
group :assets do
...
gem 'sass-rails', '~> 3.2.4'
gem 'compass-rails', '~> 1.0.3'
gem 'bootstrap-sass', '~> 2.1.1.0'
end
I've put in the import statement to my application.css.scss file:
#import "bootstrap";
I've required bootstrap in my application.js:
//= require jquery
//= require jquery_ujs
//= require bootstrap
...
and I've required bootstrap-sass in my config.ru file:
require 'bootstrap-sass'
require ::File.expand_path('../config/environment', __FILE__)
run MYAPP::Application
Anyone have any idea what the problem could be, or encountered the same problem?
Here's the git for bootstrap-sass: https://github.com/thomas-mcdonald/bootstrap-sass.git
The bootstrap-sass is not well documented, it take me some time to make a workaround.
Forget about the compass.
gemfile:
gem 'bootstrap-sass', '~> 2.1.1.0'
gem 'bootswatch-rails'
use bootswatch-rails gem can quickly change your themes
in assets/stylessheets, create a your_own_sytlesheet.css.scss
#import "bootswatch/cerulean/variables";
// Then bootstrap itself
#import "bootstrap";
// Bootstrap body padding for fixed navbar
body { padding-top: 60px; }
// Responsive styles go here in case you want them
#import "bootstrap-responsive";
// And finally bootswatch style itself
#import "bootswatch/cerulean/bootswatch";
// Whatever application styles you have go last
//#import "base";
you can change themes easily by replacing cerulean with other names.
At least it works for me now.
Figured it out...
So to get the install to work, I had to call bundle exec compass install bootstrap. This executes compass install bootstrap in the context of the bundle, which includes all the gems. However, this gave rise to some more problems.
The install wrote several new bootstrap javascript files to my assets/javascripts directory. In Rails 3.2, these are automatically loaded by the asset pipeline, but in the wrong order, so in my browser console, I was getting error messages for a missing constructor and calling 'popover' on an undefined object. After digging around, the solution was just to delete all the newly generated javascript files, as they are already included by having //= require bootstrap in application.js.
You don't need gem for this. Just copy bootstrap libs (scss & js files) to your assets.
Make sure that no more text in your application.css.scss before #import 'bootstrap';
And don't need edit config.ru file
Also look into you page code. What is displaying in application.css ?
Have you user in your controller inheritance of ApplicationController?
In your gem file try keeping bootstrap gem outside asset.
source 'https://rubygems.org'
gem 'rails', '3.2.8'
gem 'bootstrap-sass', '2.1.1'
And then run command
$ bundle install.
Then check and ensure that bootstrap is installed using command.
$bundle list

Resources