Asset pipeline in a Rails 3.2.11 app works fine with Ruby 1.9.3 but stops working in Ruby 2.0.0 - ruby

My asset pipeline was working fine in Ruby 1.9.3. When I upgrade to 2.0.0 It stops working.
In Gemfile:
gem 'jquery-rails'
In application.js file:
//= require jquery
//= require jquery_ujs
//= require bootstrap-affix
//= require bootstrap-alert
...
//= require jquery_nested_form
//= require sitengine.js
//= require_tree .
Result from .../assets/application.js in browser:
//= require jquery
//= require jquery_ujs
//= require bootstrap-affix
//= require bootstrap-alert
...
//= require jquery_nested_form
//= require my_app.js
//= require_tree .
;
Two questions:
Have you experienced this? If you have, would love to have a comment from you.
Have you found a solution? (Thanks in advance for your answer.)
Thanks!

I updated all my gems with bundle update and that did the trick.
No idea why, probably some gems were updated for ruby 2.

Related

Having issues loading reset-client on Debian distro

I'm trying to run an application that uses rest-client version 2.0.1, however when I run the application I'm getting
/opt/whitewidow/lib/imports/constants_and_requires.rb:6:in require': cannot load such file -- rest-client (LoadError) from /opt/whitewidow/lib/imports/constants_and_requires.rb:6:in<top (required)>'
from whitewidow.rb:2:in require_relative' from whitewidow.rb:2:in
What I've tried to do is edit the code to use restclient instead of rest-client but that just throws the same issue, I tried install a version lower with gem install rest-client -v 2.0 I get the same error.
Now here's the weird part, the application runs on Windows 7, but not on a Debian distro, is there a trick to running rest-client on a Linux distro? here's all the requirements:
require 'rubygems'
require 'bundler/setup'
require 'mechanize'
require 'nokogiri'
require 'rest-client'
require 'timeout'
require 'uri'
require 'fileutils'
require 'yaml'
require 'date'
require 'optparse'
require 'tempfile'
require 'socket'
require 'net/http'
require 'ipaddr'
require 'csv'
If you bundled the application on windows it will not execute properly. This is because it compiles with the windows binaries.
Try deleting your Gemfile.lock and rebundling.

Require order in a ruby script

I have a ruby script that requires 3 gems to work. My script starts as follows:
#!/usr/bin/env ruby
require 'httparty'
require 'imgkit'
require 'twitter'
Now, interestingly, the above code works, but only if I require httparty first or second. If I require it as the third dependency, I get the following:
'require': cannot load such file -- httparty (LoadError)
I'd love to learn why this is happening, so I can better understand how ruby handles gem dependencies. Many thanks!
Edit: I am using bundler. This is my Gemfile:
source 'https://rubygems.org'
ruby '2.2.2'
gem 'wkhtmltoimage-binary'
gem 'imgkit'
gem 'twitter'
gem 'rspec'
gem 'httparty'
Following tadman's advice, adding require 'bundler/setup' solved the problem. More in the docs. Thanks!

How to get bootstrap helpers using Rails 5 and Bootstrap 4

I'm working on an application upgrade from rails 4.2 (with bootstrap 3) to rails 5 (bootstrap 4.0.0.alpha3.1).
I'm using the official bootstrap-rubygem https://github.com/twbs/bootstrap-rubygem and I'm following the steps on the documentation, but the problem I have is the absence of the classical bootstrap helpers. I.e.: menu_group, nav_bar, menu_item, dropdown_divider, etc...
Is there any way to get these helpers back as on bootstrap3?
The relevant configuration I have, regarding this issue, is:
Gemfile:
gem 'rails', '~> 5.0.0'
gem 'sass-rails', '~> 5.0'
gem 'jquery-rails'
gem 'turbolinks', '~> 5'
gem 'bootstrap', '~> 4.0.0.alpha3.1'
application.js:
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .
application.scss:
#import "bootstrap";
This is due to bootstrap framework has large number of changes.

Rails precompile assets on Heroku Sprockets::FileNotFound

I try to deploy my simple Rails app to Heroku. This app is just attempt to use bower with Heroku.
Unfortunately I have problems with precompile assets on Heroku.
This gives me error Sprockets::FileNotFound.
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: Sprockets::FileNotFound: couldn't find file './app/App'
remote: (in /tmp/build_fe6dc0e2c0063705b279b26e4aa2432d/app/assets/javascripts/application.js:12)
I don't know what can be the cause. App.js is my own file and it surely exists.
Need to mention that rake assets:precompile work properly on my local machine.
This is my applications.js which includes all other files
//= require jquery
//= require jquery_ujs
//= require vendor/angular/angular
//= require vendor/angular-route/angular-route
//= require vendor/angular-resource/angular-resource
//= require vendor/angular-sanitize/angular-sanitize
//= require vendor/moment/moment
//= require vendor/angular-moment/angular-moment
//= require ./app/App
//= require ./app/router
//= require_tree ./app/controllers
//= require_tree ./app/directives
//= require_tree ./app/filters
In some similar questions I found advice to run heroku repo:purge_cache.
But this failed to me too.
~/tmp/repo_tmp $ cd unpack
~/tmp/repo_tmp/unpack $ tar -zxf ../repo-cache.tgz
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
All source code is published at GitHub
https://github.com/ivanovalexey/bowerrr
Could some one help me figure it out?
Thank you.
Solved. The problem was with file name ./app/App.js. I renamed it to ./app/main.js and it worked. Still wonder why it doesn't matter locally.

Rails 4 Assets are not compiling in production environment

My app is running in dev environment. I am using JQCloud.
Its working fine in development mode but when i run following command
RAILS_ENV=production rake assets:precompile
All assets precompile but after running my server in production mode i am getting following error.
jQCloud is not a function
application.css.scss
*= require_tree .
*= require_self
*= require font-awesome
*/
appication.js
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require_tree .
dashing widegts index.js
//= require_tree .
//= require highcharts/highstock
//= require highcharts/highcharts-more
//= require highcharts/modules/exporting
//= require jquery-ui
//= require jqcloud
Facing error following errors
Uncaught TypeError: $(...).jQCloud is not a function
Uncaught ReferenceError: Highcharts is not defined

Resources