I've inherited a Rails app and am currently being defeated by the above error. The weird thing is this codebase is running on Heroku without this error, so I don't know how.
Here is the full error output:
ActionView::Template::Error (File to import not found or unreadable: select2.
Load paths:
/app/app/assets/javascripts
/app/app/assets/stylesheets
/app/app/assets/widget_javascripts
/usr/local/bundle/gems/coffee-rails-5.0.0/lib/assets/javascripts
/usr/local/bundle/gems/activeadmin-searchable_select-1.5.0/app/assets/javascript
/usr/local/bundle/gems/activeadmin-searchable_select-1.5.0/app/assets/stylesheets
/usr/local/bundle/gems/select2-rails-4.0.13/vendor/assets/javascripts
/usr/local/bundle/gems/select2-rails-4.0.13/vendor/assets/stylesheets
/usr/local/bundle/gems/activeadmin_quill_editor-0.3.4/app/assets/javascripts
/usr/local/bundle/gems/activeadmin_quill_editor-0.3.4/app/assets/stylesheets
/usr/local/bundle/gems/activeadmin-2.9.0/app/assets/javascripts
/usr/local/bundle/gems/activeadmin-2.9.0/app/assets/stylesheets
/usr/local/bundle/gems/activeadmin-2.9.0/vendor/assets/javascripts
/usr/local/bundle/gems/jquery-rails-4.4.0/vendor/assets/javascripts
/usr/local/bundle/gems/formtastic-4.0.0/app/assets/stylesheets
/usr/local/bundle/gems/actioncable-6.1.4.1/app/assets/javascripts
/usr/local/bundle/gems/activestorage-6.1.4.1/app/assets/javascripts
/usr/local/bundle/gems/actionview-6.1.4.1/lib/assets/compiled
/app/node_modules):
2: <html>
3: <head>
4: <title><%= yield :title_tag %></title>
5: <%= stylesheet_link_tag "application", media: "all" %>
6: <%= csrf_meta_tags %>
7: <%= csp_meta_tag %>
8: </head>
app/assets/stylesheets/active_admin.scss:5
app/views/layouts/application.html.erb:5
I, [2022-05-04T10:39:06.704054 #20] INFO -- : source=rack-timeout id=af5eb0c9-e88d-4992-9895-90fa372b4f73 timeout=15000ms service=1506ms state=completed
I've read this answer, and consequently added require references to select2 in the following files:
app/assets/stylesheets/application.css
app/assets/stylesheets/active_admin.scss
app/assets/javascripts/application.js
app/assets/javascripts/active_admin.js
...e.g. in active_admin.scss I've added
//= require select2
Someone also said the config.assets.compile setting may be relevant here. In my environment file, it's commented-out.
# config.assets.compile = false
Here's how I'm starting the app (via Docker):
gem install bundler -v 2.2.21 && bundle install && rails db:migrate && rails server --port 3000 --binding 0.0.0.0
And here's my Gemfile (there's no mention of select2 in it, but it does feature in the Gemfile.lock, most likely because it's a dependency of another Gem, namely activeadmin-searchable_select.
source 'https://rubygems.org'
ruby '2.7.5'
gem 'activeadmin', '2.9.0'
gem 'activeadmin_quill_editor'
gem 'active_reporting'
gem 'activeadmin-searchable_select'
gem 'active_admin_import'
gem 'api_guard'
gem 'apipie-rails'
gem 'azure-storage-blob', require: false
gem 'bcrypt'
gem 'blind_index'
gem 'browser'
gem 'coffee-rails'
gem 'dalli'
gem 'devise'
gem 'emoji_flag'
gem 'forecast_io'
gem 'flag_shih_tzu'
gem 'groupdate'
gem 'i18n-active_record', github: 'svenfuchs/i18n-active_record', require: 'i18n/active_record'
gem 'twilio-ruby'
gem 'feedjira'
gem 'httparty', '0.18.1'
gem 'jquery-rails'
gem 'jwt'
gem 'lockbox'
gem 'pg'
gem 'puma'
gem 'rails', '6.1.4.1'
gem 'rack-cors'
gem 'rack-timeout'
gem 'redis'
gem 'rollbar'
gem 'rqrcode'
gem 'rubyzip'
gem 'ruby-openai'
gem 'sidekiq'
gem 'sinatra', require: nil # if you require 'sinatra' you get the DSL extended to Object
gem 'slack-notifier'
gem 'slim' # slim and Sinatra are for the Sidekiq web ui
gem 'will_paginate'
group :assets do
gem 'sass-rails', '~> 5.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'mini_racer', github: 'sqreen/mini_racer', branch: 'use-libv8-node'
gem 'uglifier', '>= 1.0.3'
end
group :development do
gem 'dotenv-rails', groups: :test
gem 'launchy'
gem 'listen'
gem 'pry'
gem 'rubocop'
gem 'spring'
end
group :test do
gem 'capybara'
gem 'database_cleaner', '2.0.1'
gem 'factory_bot_rails'
gem 'ffaker'
gem 'rspec-rails', '4.0.0.rc1'
end
---- EDIT ----
active_admin.js (top of):
//= require active_admin/base
//= require active_admin/searchable_select
//= require activeadmin/quill_editor/quill
//= require activeadmin/quill_editor_input
Related
I've updated my app to rails 5.1 and spree to spree 3.5 this caused several problems with the latest being.
ActionView::Template::Error (couldn't find file 'jquery.validate/jquery.validate.min' with type 'application/javascript'
I've tried installing the gems like gem 'jquery-rails' gem 'rails-ujs,'~> 0.1.0' gem "jquery-ui-rails" gem 'jquery-validation-rails' and even added the files to my JavaScript folder.
Still no succes.
Anyone know the cause of the problem and how to solve it?
gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails'
# Use sqlite3 as the database for Active Record
# gem 'sqlite3'
gem 'pg', '< 1'
# Use SCSS for stylesheets
gem 'sass-rails'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails'
# See https://github.com/rails/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
gem 'truncate_html', '~> 0.9.3'
# Use jquery as the JavaScript library
gem 'jquery-rails'
gem 'rails-ujs', '~> 0.1.0'
gem "jquery-ui-rails"
gem 'jquery-validation-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', group: :doc
gem 'rake'
gem 'rspec'
gem 'kramdown'
gem 'thor', '0.19.1'
gem 'spree_braintree_vzero', github: 'spree-contrib/spree_braintree_vzero'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'capistrano-passenger'
gem 'capistrano-rails'
gem 'capistrano-rvm'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
gem 'spree', '~> 3.5.0.rc2'
gem 'spree_auth_devise', '~> 3.3'
gem 'spree_gateway', '~> 3.3'
gem 'devise'
gem 'materialize-sass'
gem 'active_link_to'
#gem 'mollie-api-ruby', '< 3.2'
# gem 'spree_mollie', github: 'salman15/mollie_spree_2017', branch: 'stable'
#gem 'spree_mollie', github: 'ttcremers/spree_mollie', branch: 'stable'
gem 'spree_mail_settings', github: 'spree-contrib/spree_mail_settings'
# gem 'spree_i18n', github: 'spree-contrib/spree_i18n'
# gem 'spree_globalize', github: 'spree-contrib/spree_globalize', branch: 'master'
gem "mini_magick"
gem 'spree_mollie_gateway'
# gem 'rails-i18n', github: 'svenfuchs/rails-i18n', branch: 'rails-4-x' # For 4.x
# gem 'globalize', '~> 5.1.0'
all.js/application.js
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require jquery.validate
//= require spree/frontend
//= require_tree .
//= require spree/frontend/spree_auth
//= require spree/frontend/spree_braintree_vzero
This fixed the problem for me: I just removed the line
//= require jquery.validate/jquery.validate.min
from frontend.js
I have a Rails application which was using Mongoid 4.0.2. I upgraded Mongoid to version 5.0.0 and start getting this error
....gems/2.2.0/gems/less-rails-2.7.0/lib/less/rails/railtie.rb:19:in `block in <class:Railtie>': undefined method `register_preprocessor' for nil:NilClass (NoMethodError)
How to fix this issue or is any manual how to upgrade Mongoid to version 5.0.0 ?
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0.beta4'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.0.beta1'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jQuery as the JavaScript library
gem 'jquery-rails', '~> 4.0.0.beta2'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
#new gems
#database
gem 'mongoid', '~> 5.0.0.beta'
gem "mongoid-paperclip", :require => "mongoid_paperclip"
gem 'bson_ext'
#stile
gem "therubyracer"
gem "less-rails" #Sprockets (what Rails 3.1 uses for its asset pipeline) supports LESS
gem "twitter-bootstrap-rails"
gem 'bootstrap_form'
gem 'bootstrap-sass', '~> 3.3.4'
gem 'bootswatch-rails'
gem 'simple_form'
gem 'mongo'
gem "figaro"
gem 'sidekiq'
gem 'sidekiq-status'
gem 'rubyzip'
#gem 'sidekiq_status'
#gem 'sidekiq-status'
gem 'sinatra', require: false
gem 'slim'
gem 'capistrano', '~> 3.1.0'
# rails specific capistrano funcitons
gem 'capistrano-rails', '~> 1.1.0'
gem 'capistrano-rails-console'
# integrate bundler with capistrano
gem 'capistrano-bundler'
# if you are using RBENV
gem 'capistrano-rbenv', "~> 2.0"
gem 'capistrano-sidekiq', github: 'seuros/capistrano-sidekiq'
gem 'capistrano-passenger'
gem 'utf8-cleaner'
gem "devise"
gem 'rollbar', '~> 1.5.3'
#gem 'bson', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
gem 'thin'
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0.0.beta4'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
#new gems
gem "rspec-rails"
gem 'pry-rails'
gem 'pry-rescue'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'better_errors'
#gem 'mongoid-rspec', '~> 2.1.0'
end
It looks like the error has appeared again in less-rails. The error is not related to Mongoid at all. I started getting the error a couple of days ago on my development server. I decided to check Github to see if an issue was reported about this. I found the following issue addressing the error.
https://github.com/metaskills/less-rails/pull/112
I changed my Gemfile to the following as provided on the link which corrected the error.
gem "less-rails", :git => 'https://github.com/suzan2go/less-rails.git', :branch => 'fix-nomethoderror-for-sprockets3'
As of now this solution has not been applied to the gem. I guess it will be soon.
Most important thing to look for while upgrading to Mongoid 5 is mongoid.yml
From:
<%= rails_env %>:
sessions:
default:
database: <%= mongodb_database %>
hosts:
- <%= mongodb_staging_host %>
username: <%= mongodb_user %>
password: <%= mongodb_password %>
options:
read: :primary_preferred
To:
<%= rails_env %>:
clients:
default:
database: <%= mongodb_database %>
hosts:
- <%= mongodb_staging_host %>
options:
user: <%= mongodb_user %>
password: <%= mongodb_password %>
read:
mode: :primary_preferred
Change sessions to clients
Move username (will become user) and password into options
change read mode as shown, if you have any.
Bottomline is to check mongoid.yml thoroughly while comparing with this page
Here how I fixed this issue
Removed from Gemfile gem "less-rails"
From application.rb removed require "mongo"
In mongoid.yml changed sessions: to clients:
I am having an issue with foundation 5, rails 4.1.0, as per screenshot, links are underlined, search box is off.
I have created a separate dummy rails app with the same spec and don't see the same issue
I've tried without turbolinks, and different topbar configurations.
any ideas where to troubleshoot this?
Screenshot:
http://postimg.org/image/ohtwc60rj/
application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require foundation
//= require_tree .
$(function() {
$(document).foundation();
});
`
application.css.scss
*= require_tree .
*= require_self
*/
gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.0'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
gem 'foundation-rails'
gem 'rails_12factor'
gem 'activeadmin', github: 'gregbell/active_admin'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
group :development do
#gem 'sqlite3'
gem 'rspec-rails'
gem 'guard-rspec'
gem 'slop'
gem 'guard-livereload', require: false
gem 'jazz_hands'
end
gem 'pg', '0.17.1'
group :test do
gem 'rspec-rails'
gem 'capybara'
gem 'rb-fsevent', :require => false
gem 'growl'
gem 'guard-spork', :github => 'guard/guard-spork'
gem 'spork', :github => 'sporkrb/spork'
end
#Server monitoring
gem 'newrelic_rpm'
Found that active admin was conflicting. commented out active_admin.css.scss resolved the issue. That put me in the right direction
Fix from Foundation when using active admin http://foundation.zurb.com/forum/posts/1359-foundation-5-impacted-by-active-admin-on-rails-4
I am trying to deploy an app in rails 3.2.16, with capistrano on a vps. This is my first time doing that. During the deployment process, I get the following error: "couldn't find file "chosen-jquery" '. The rpoblem is that my gem versions and generally the whole environment is the same on the server and my testing machine. I get the error during the "assets:precompile" command execution.
Any suggestions?
I am using the gem chosen -v 1.0.2, rails 3.2.16 and Ruby 1.9.3.
Here is my gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.16'
gem 'mysql2'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'ckeditor', '4.0.4'
gem 'carrierwave', '0.8.0'
gem 'devise', '2.2.3'
gem 'globalize3', '0.3.0'
gem 'babosa', '0.3.9'
gem 'haml', '4.0.4'
gem 'friendly_id', '4.0.9'
gem 'simple_form', '2.0.4'
gem 'kaminari', '0.14.0'
gem 'nokogiri', '1.6.1'
gem 'jquery-fileupload-rails', '0.4.0'
gem 'ancestry', '1.3.0'
gem 'ransack', '0.7.2'
gem 'simple-navigation', '3.10.0'
gem 'mime-types', '~>1.21'
gem 'mini_magick', '3.5.0'
gem 'acts_as_list', '0.1.9'
gem 'chosen-rails'
gem 'pry'
gem 'passenger'
and my application.js manifest:
//= require jquery-1.10.2.min
//= require jquery_ujs
//= require ckeditor/init
//= require jquery.fancybox-1.3.4.pack
//= require jquery.easing-1.3.pack
//= require jquery.mousewheel-3.0.4.pack
//= require chosen-jquery
//= require scripts
//= require admin_scripts
Thank you in advance for your time and effort :)
You can try require the library manually (as file)
Just restart rails server. I had the same problem on Rails 4.1.5. I restarted rails server and it worked. See this Github issue
Up until recently my SaSS has been compiling without a hitch, earlier tonight I started to get the following errors.
I have tried rejigging my Gemfile, but I can not for the live of me workout how to get the files to compile and serve the correct css.
Started GET "/assets/application.css" for 127.0.0.1 at 2013-03-11 21:27:35 +1100
Error compiling asset application.css:
Sass::SyntaxError: File to import not found or unreadable: foundation/common/ratios.
Load paths:
Sass::Rails::Importer(/Users/paulmcguane/Sites/Rails/teammngt/app/assets/stylesheets/app.css.scss)
/Users/paulmcguane/Sites/Rails/teammngt/app/assets/stylesheets
/Users/paulmcguane/.rvm/gems/ruby-1.9.3-p125/gems/compass-0.12.2/frameworks/blueprint/stylesheets
/Users/paulmcguane/.rvm/gems/ruby-1.9.3-p125/gems/compass-0.12.2/frameworks/compass/stylesheets
Compass::SpriteImporter
(in /Users/paulmcguane/Sites/Rails/teammngt/app/assets/stylesheets/app.css.scss)
Served asset /application.css - 500 Internal Server Error
gem file
source 'https://rubygems.org'
gem 'rails', '3.2.3'
gem 'therubyracer', :platform => :ruby
gem 'better_errors'
# Database Gems
gem 'yaml_db'
gem 'thin'
gem 'pg'
gem 'rb-readline'
#Application Processing
gem 'haml'
gem 'json'
gem 'spreadsheet'
gem 'paperclip'
#Phone conversion
gem 'countries'
gem 'phony'
gem 'phony_rails'
#Application required gems
gem 'zurb-foundation'
gem 'twilio-ruby'
gem 'simple-navigation', '~> 3.7.0'
gem 'kaminari'
gem 'client_side_validations'
gem 'event-calendar', :require => 'event_calendar'
gem 'watu_table_builder', :require => 'table_builder'
gem 'best_in_place'
gem 'to_xls', :git => 'https://github.com/dblock/to_xls.git', :branch => 'to-xls-on-models'
#Auth and Management
gem 'devise'
gem 'cancan'
gem 'switch_user'
gem 'paper_trail', '~> 2'
gem 'omniauth-facebook'
gem 'bcrypt-ruby', '~> 3.0.0'
gem 'fb_graph'
#gem 'announcements'
# 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'
gem 'uglifier', '>= 1.0.3'
# Add these gems
gem 'compass-rails'
gem 'zurb-foundation'
end
gem 'jquery-rails'
gem 'compass'
Judging from the look of your gemfile, you're not specifying a version of zurb-foundation.
The short answer is, specify gem 'zurb-foundation', '= 3.2.5' in your gemfile instead.
Otherwise, if you've run a bundle update anytime recently, your zurb-foundation gem has upgraded to 4.x which does not include a path to foundation/common/ratios anymore.
I was banging my head against the wall with this on Heroku, which I talk about in Avoid a Headache: Precompiling Zurb (Foundation) on Heroku