Deployment rails app. JQuery-UI error - ruby-on-rails

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'

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'

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

Related

Couldn't find "fullcalendar"

We're using Rails Assets in our project and we're in the process of updating Ruby from 2.3.7 to 2.4.7, following this guide. I think I've resolved all the gems issues, but when I'm trying to run rspec or navigate to any admin page, I'm greeted with this error:
couldn't find file 'fullcalendar'
This is one of the Rails Assets mentioned above, and I'm not sure why this is happening.
My gemfile:
source 'https://rails-assets.org' do
gem 'rails-assets-jquery'
gem 'rails-assets-jquery-ujs'
gem 'rails-assets-jquery-ui'
gem 'rails-assets-js-cookie'
gem 'rails-assets-lodash'
gem 'rails-assets-highcharts'
# gem 'rails-assets-quill'
gem 'rails-assets-select2'
gem 'rails-assets-select2-bootstrap-css'
gem 'rails-assets-slick.js'
gem 'rails-assets-picturefill'
gem 'rails-assets-scrollmagic'
gem 'rails-assets-gsap'
gem 'rails-assets-fullcalendar'
gem 'rails-assets-moment'
gem 'rails-assets-jstzdetect'
gem 'rails-assets-blueimp-file-upload'
gem 'rails-assets-air-datepicker'
end
/app/views/layouts/admin.haml:
= javascript_include_tag 'admin'
/app/assets/javascripts/admin.js
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery-ujs
//= require jquery-ui/jquery-ui
//= require lodash
//= require bootstrap
//= require moment
//= require quill
//= require fullcalendar
//= require select2
//= require jstzdetect
//= require cocoon
//= require blueimp-file-upload/jquery.iframe-transport.js
//= require blueimp-file-upload/vendor/jquery.ui.widget.js
//= require blueimp-file-upload/jquery.fileupload.js
//= require_tree ./admin
What have me scratching my head is that the assets above fullcalendar are loading fine, but this one throws an error.
This app is running on Rails 4.2.7.1 and ruby 2.3.7. I'm trying to update Ruby version to ruby 2.4.7.
Try replacing require fullcalendar with
require fullcalendar/core/main.js
require fullcalendar/daygrid/main.js
Just a guess based on the doc
Alternatively, just remove it from assets and put the files directly in vendor folder; or use this gem.

couldn't find file 'angularjs/rails/resource' with type 'application/javascript'):

Error come on this line
//= require angularjs/rails/resource
It gives an error
ActionView::Template::Error (couldn't find file 'angularjs/rails/resource' with type 'application/javascript'):
Gemfile
# angularjs
gem 'angularjs-rails-resource'
gem 'angular-rails-templates'
gem 'angular_rails_csrf'
You can try to use angularjs-rails gem.
This works fine for me
gem 'angularjs-rails'
Then in your .js file you can require like
//= require angular
//= require angular-resource

Sprockets cant find asset from rails-assets.org

I try to install react-router and material-ui on my rails 4 app but I get Sprockets::FileNotFound error for react-router and material-ui. I follow instructions from rails-assets.org.
My Gemfile:
source 'https://rails-assets.org' do
gem 'rails-assets-classnames'
gem 'rails-assets-lodash'
gem 'rails-assets-react-router'
gem 'rails-assets-material-ui'
end
application.js
//= require jquery
//= require lodash
//= require jquery_ujs
//= require react
//= require classnames
//= require react_ujs
//= require react-router
//= require turbolinks
//= require_tree .
And after bundle I got this notification on some gems This component doesn't define main assets in bower.json.. Thank you for your time and I hope we work this out.
UPD 1:
I found kind of a solution on stackoverflow but I would like to stick to rails-assets.org way if possible.
ruby '2.2.0'
rails '4.2.3'
Might be easy to forget, but have you restarted your (running) rails server?
Started to use rails-assets yesterday as well and it showed me the exact same problem (Sprockets::FileNotFound).
I restarted the running server in the console and the problem was solved.
Rails 4.2.5
/ Ruby 2.3.

Rails: Bootstrap stopped working after a precompile

For some reason my bootstrap broke after I precompiled my code. This started because I couldn't push to heroku because of a precompile error.
So here are the contents of my application.js file:
//= require jquery
//= require jquery_ujs
//= require jquery-ui
//= require dataTables/jquery.dataTables
//= require dataTables/jquery.dataTables.bootstrap3
//= require bootstrap
//= require bootstrap/dropdown
//= require_tree .
Maybe the order is wrong? I just added .../dropdown hoping it would help, but it did not. I just realized I can actually remove both bootstrap lines without affecting my resulting site.
For my gems, I have:
gem 'bootstrap-sass', "~>3.0.3.0"
...
gem 'bootstrap-will_paginate', '0.0.6'
Here is a link to my other question, which is similar but less focused: Ruby on Rails: Ran rake assets:precompile and now both local and heroku deployment don't include bootstrap
Any help would be greatly appreciated. I'm getting pretty frustrated, it's been several days of failed action.

When installing a gem (bootstrap-wysihtml5) do I have to manually move javascript and css files?

I think I am missing a vital step:
When installing a gem (ie. bootstrap-wysihtml5) what steps should I take for it to correctly find and reference the javascript and css files.
I add gem bootstrap-wysihtml5 to my gemfile, and run bundle install.
I place //= require bootstrap-wysithtml5 in application.js and *= require bootstrap-wysithtml5 in application.css.
I get the following error:
Error compiling CSS asset
Sprockets::File not found: couldnt find file 'bootstrap-wysihtml5.css'
Do I have to manually copy the js and css to the relevant app/assets file, or is there a crucial step I'm missing?
As Billy said, the correct gem is bootstrap-wysihtml5-rails. The gem installs the JS/CSS without further effort on your part.
Add this to your Gemfile:
gem 'bootstrap-wysihtml5-rails'
Add this to app/assets/javascripts/application.js:
//= require bootstrap-wysihtml5
Add this to app/assets/stylesheets/application.css:
*= require bootstrap-wysihtml5
Note that bootstrap-wysihtml5-rails requires Bootstrap. If you have not already added Bootstrap to your project, follow these steps from the creator of this gem:
In Gemfile, add the following:
gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails',
:github => 'anjlab/bootstrap-rails'
Rename app/assets/stylesheets/application.css to app/assets/stylesheets/application.css.scss
Add the following to app/assets/stylesheets/application.css.scss:
#import "twitter/bootstrap";
Add the following to app/assets/javascripts/application.js:
//= require twitter/bootstrap
Once the gem & Bootstrap are both installed, initialize wysihtml5.
<textarea id="some-textarea" class='wysihtml5' placeholder="Enter text ..."></textarea>
<script type="text/javascript">
$(document).ready(function(){
$('.wysihtml5').each(function(i, elem) {
$(elem).wysihtml5();
});
});
</script>
I found the solution! Thanks for your help guys.
By moving the position of the javascript references to this order, it now seems to work.
//= require jquery
//= require jquery_ujs
//= require bootstrap-wysihtml5/b3
//= require bootstrap/bootstrap
I have no idea why the order would make such a difference. But it works now! Thanks.

Resources