Rails Webpacker not finding modules (just upgraded to ROR 6.1) - ruby-on-rails

I've just upgraded to ROR 6.1 from 5.4 and have had to start using Webpacker (just used Sprockets before). I've been through the Rails upgrade wizard and installed up-to-date packages through yarn, but can't get Webpacker working.
Whenever I run 'bin/webpack-dev-server', I get multiple error messages for each module saying this:
ERROR in ./app/javascript/packs/application.js
Module not found: Error: Can't resolve '#rails/activestorage' in '/Users/oli/pre_product/app/javascript/packs'
resolve '#rails/activestorage' in '/Users/oli/xxx/app/javascript/packs'
Parsed request is a module
using description file: /Users/oli/xxx/package.json (relative path: ./app/javascript/packs)
Field 'browser' doesn't contain a valid alias configuration....
Then when I run the app locally(through NGROK), I see Webpacker requesting a file in 'public/packs/js' that doesn't exist. There's other compiled files, but none with the correct name.
It seems like Webpacker is looking in the wrong place for modules, but everything in the webpacker.yml file seems fine.
Any help would be greatly appreciated!
Oli
package.json:
{
"name": "XXX",
"private": true,
"dependencies": {
"#babel/preset-react": "^7.6.3",
"#rails/webpackerj": "^6.0.0-pre.1",
"#shopify/app-bridge": "^1.28.0",
"#shopify/app-bridge-utils": "^1.28.0",
"#shopify/polaris": "^5.12.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
"chartjs-plugin-annotation": "^0.5.7",
"prop-types": "^15.7.2",
"rails-ujs": "^5.2.4-4",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react_ujs": "^2.6.0",
"turbolinks": "^5.2.0",
"typescript": "^4.1.3",
"webpack-cli": "^4.3.0"
},
"devDependencies": {
"non-digest-webpack-plugin": "0.0.1",
"webpack-dev-server": "^3.11.1"
}
}
webpacker.yml:
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: app/javascript
source_entry_path: packs
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
webpack_compile_output: true
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
additional_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
# Extract and emit a css file
extract_css: false
static_assets_extensions:
- .jpg
- .jpeg
- .png
- .gif
- .tiff
- .ico
- .svg
- .eot
- .otf
- .ttf
- .woff
- .woff2
extensions:
- .mjs
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
development:
<<: *default
compile: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
pretty: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: '**/node_modules/**'
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Extract and emit a css file
extract_css: true
# Cache manifest.json for performance
cache_manifest: true
Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.5.8'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.1.0'
# Use sqlite3 as the database for Active Record
# Use Puma as the app server
gem 'puma', '~> 5.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 6.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'mini_racer', platforms: :ruby
group :production do
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
end
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
gem 'sprockets', '~> 3.0'
gem "clearance"
gem 'spec', '~> 5.3', '>= 5.3.4'
gem 'rspec'
gem 'webpacker'
gem 'jquery-rails'
gem 'chart-js-rails', '~> 0.1.6'
gem 'image_processing', '~> 1.2'
gem 'chartjs-ror'
gem 'inline_svg'
gem 'mailgun-ruby', '~>1.1.6'
gem 'liquid'
# Use Redis adapter to run Action Cable in production
#gem 'redis', '~> 4.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use ActiveStorage variant
# gem 'mini_magick', '~> 4.8'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.4', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 4.1.0'
gem 'sqlite3'
# Display performance information such as SQL time and flame graphs for each request in your browser.
# Can be configured to work on production as well see: https://github.com/MiniProfiler/rack-mini-profiler/blob/master/README.md
gem 'rack-mini-profiler', '~> 2.0'
gem 'listen', '~> 3.3'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
gem "non-stupid-digest-assets"
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 3.26'
gem 'selenium-webdriver'
# Easy installation and use of chromedriver to run system tests with Chrome
gem 'webdrivers'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'rake'
gem 'shopify_app', '~> 15.0'
gem 'shopify_api', '~> 9.0'
gem 'httparty'
#for CORS, i.e. external domain requests via the api controller
gem 'rack-cors'
gem 'whenever', require: false
app/javascript/packs/application.js:
/* eslint no-console:0 */
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
//
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
// layout file, like app/views/layouts/application.html.erb
// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
console.log('Hello World from Webpacker')
require("#rails/ujs").start()
require("turbolinks").start()
require("#rails/activestorage").start()
require("channels")
require("jquery");
// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
require("shopify_app")

run yarn add #rails/activestorage
It resolves this error

Related

Rails cannot fetch application-xxxxxx.js webpack bundle - 404 error

I recently updated webpacker, babel, and many other packages on my Rails project so that node-sass would work on the heroku-20 stack, and after enough fiddling webpacker is able to compile and start but when attempting to load any of the pages, Rails attempts to fetch /packs/js/application-44959decf6e2f6f8700f.js when Webpacker shows me it is bundled at /packs/application-17d61f0126c1ef6152fd.js. None of my React JS loads, only the Rails-rendered part shows.
My project is Ruby on Rails 5.2.8 (Ruby 2.7) with #rails/webpacker updated to 5.3.0, Webpack updated to 5.1.0, Node updated to 14.18.1. React version is 16.4.1.
Things I have tried:
npx webpack init
bundle exec rails webpacker:install
copying config files from another app with the same Node/webpack versions and resetting them after getting the same errors
Completely stuck on this, any help is appreciated.
package.json:
{
"name": "xxxxxxxx",
"private": true,
"dependencies": {
"#rails/actioncable": "^6.0.5",
"#rails/webpacker": "5.3.0",
"axios": "^0.17.1",
"babel-loader": "8.1.0",
"#babel/preset-react": "^7.18.6",
"babel-plugin-syntax-dynamic-import": "7.0.0-beta.3",
"babel-plugin-transform-object-rest-spread": "7.0.0-beta.3",
"babel-preset-env": "1.7.0",
"babel-preset-react": "6.24.1",
"compression-webpack-plugin": "^1.1.6",
"css-loader": "^5.1.1",
"file-loader": "^6.1.0",
"immutability-helper": "^2.8.1",
"lodash.groupby": "^4.6.0",
"lodash.snakecase": "^4.1.1",
"nanoid": "^2.1.1",
"sass": "^1.56",
"postcss-loader": "^7.0.1",
"prop-types": "^15.6.0",
"react": "^16.4.1",
"react-animate-height": "^2.0.7",
"react-copy-to-clipboard": "^5.0.1",
"react-datepicker": "^2.8.0",
"react-dom": "^16.2.0",
"react-geosuggest": "^2.9.0",
"react-inlinesvg": "^1.1.7",
"react-select": "^2.4.2",
"react-tagsinput": "^3.19.0",
"react-transition-group": "^2.2.1",
"reactstrap": "^6.5.0",
"sass-loader": "^12.6.0",
"uglifyjs-webpack-plugin": "^1.1.8",
"webpack": "^5.1.0",
"webpack-cli": "^4.10.0",
"webpacker-react": "^0.3.2"
},
"devDependencies": {
"babel-plugin-transform-class-properties": "6.24.1",
"#webpack-cli/serve": "^2.0.0",
"eslint": "4.19.1",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"webpack-dev-server": "~3"
},
"scripts": {
"eslint": "./node_modules/.bin/eslint --ext .js,.jsx ./app/javascript"
},
"engines": {
"node": "14.18.x"
}
}
webpack.config.js
const path = require("path");
const isProduction = process.env.NODE_ENV == "production";
const config = {
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
// Creates `style` nodes from JS strings
"style-loader",
// Translates CSS into CommonJS
"css-loader",
// Compiles Sass to CSS
"sass-loader",
],
},
],
},
entry: "./src/index.js",
output: {
path: path.resolve(__dirname, "dist"),
},
devServer: {
open: true,
host: "localhost",
port: 3035
},
};
module.exports = () => {
if (isProduction) {
config.mode = "production";
} else {
config.mode = "development";
}
return config;
};
config/webpacker.yml
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: app/javascript
source_entry_path: packs
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
check_yarn_integrity: false
webpack_compile_output: true
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
# Extract and emit a css file
extract_css: false
static_assets_extensions:
- .jpg
- .jpeg
- .png
- .gif
- .tiff
- .ico
- .svg
- .eot
- .otf
- .ttf
- .woff
- .woff2
extensions:
- .jsx
- .mjs
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
development:
<<: *default
compile: true
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
check_yarn_integrity: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
pretty: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: '**/node_modules/**'
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Extract and emit a css file
extract_css: true
# Cache manifest.json for performance
cache_manifest: true
.babelrc
{
"presets": [
"#babel/preset-env",
"#babel/preset-react"
],
"plugins": [
"syntax-dynamic-import",
"transform-object-rest-spread",
"#babel/plugin-proposal-object-rest-spread",
[
"transform-class-properties",
{
"spec": true
}
]
]
}
Gemfile
source 'https://rubygems.org'
ruby '~> 2.7.6'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
"https://github.com/#{repo_name}.git"
end
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.8'
# Use postgresql as the database for Active Record
gem 'pg', '~> 1.2.3'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'letter_opener', '>= 1.8.1'
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'activerecord-import'
gem 'active_model_serializers'
gem 'geocoder'
gem 'searchkick', '~> 5.0.3'
gem 'devise'
gem 'addressable'
gem 'parallel'
gem 'oj'
gem 'webpacker', '~> 4.3.0'
gem 'webpacker-react', '~> 0.3.2'
gem 'bootstrap', '~> 4.0.0'
gem 'kaminari'
gem 'paranoia', '~> 2.2'
gem 'cocoon'
gem 'jquery-rails'
gem 'select2-rails'
# gem 'select2-rails-latest' # update select2 to make dropdowns case-insensitive
gem 'attribute_normalizer'
gem 'aws-sdk-s3', '~> 1'
gem 'aasm'
gem 'bunny'
gem 'kt-paperclip', '~> 6.4.2'
gem 'font-awesome-rails'
gem 'lograge'
gem 'rollbar'
gem 'httparty'
gem 'restforce'
gem 'sidekiq'
gem 'postmark-rails'
gem "mimemagic", path: 'vendor/gems/mimemagic-0.3.2'
gem 'paper_trail'
gem 'pry'
gem 'elasticsearch'
group :test do
gem 'timecop'
gem 'climate_control'
end
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
gem 'rspec-rails'
gem 'foreman'
gem "factory_bot_rails"
gem 'faker'
gem 'capybara'
gem 'database_cleaner-active_record'
gem 'selenium-webdriver', '~> 3.14'
gem 'capybara-screenshot'
gem 'rubocop', '~> 1.29', require: false
gem 'figaro'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'pry-rails'
end
group :development do
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
gem 'web-console', '>= 3.3.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'rspec_junit_formatter'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Procfile.dev
web: bin/rails server -p 3002
webpack: yarn run webpack serve --mode=development
worker: bundle exec sidekiq -C config/sidekiq.yml
es: bin/elasticsearch-8.2.3/bin/elasticsearch
Solved by switching to bin/webpack-dev-server instead of yarn run webpack serve in Procfile.dev. I then had to copy some intricate configuration files in config/webpack/ from another project with the same setup, then configure all of the loaders.

How to fix "Sprockets::FileNotFound: couldn't find file 'turbolinks' with type 'application/javascript'"

I can't push my code to heroku but it works in local.
When i make rake assets:precompile in terminal, i've this answer:
rake aborted!
Sprockets::FileNotFound: couldn't find file 'turbolinks' with type 'application/javascript' I don't want use Sprockets anymore
I tryed this: https://www.innoq.com/en/blog/rails-custom-elements-with-turbolinks-webpack/
but when i make :
class ApplicationController < ActionController::Base
include Turbolinks::Redirection
# ...
end
I've this error uninitialized constant ApplicationController::Turbolinks from error consol
My application.js from app/javascript/packs/
import Turbolinks from 'turbolinks'
Turbolinks.start()
import '../css/application.scss'
import 'bootstrap'
My package.json
{
"name": "**********",
"private": true,
"dependencies": {
"#rails/webpacker": "3.5",
"bootstrap": "^4.2.1",
"jquery": "^3.3.1",
"popper.js": "^1.14.6",
"turbolinks": "^5.2.0"
},
"devDependencies": {
"webpack-dev-server": "2.11.2"
},
"version": "1.0.0",
"main": "index.js",
"repository": "git#github.com:******/*************.git",
"author": "******* <******#email.com>",
"license": "MIT"
}
My Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.6.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.2.2'
gem 'pg', '>= 0.18', '< 2.0'
gem 'puma', '~> 3.11'
gem 'webpacker'
gem 'jbuilder', '~> 2.5'
gem 'simple_form'
gem 'postmark-rails'
gem 'cloudinary'
gem 'dotenv-rails', groups: [:development, :test]
gem 'rails_admin'
gem 'turbolinks', require: false
gem 'bootsnap', '>= 1.1.0', require: false
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'web-console', '>= 3.3.0'
gem 'listen', '>= 3.0.5', '< 3.2'
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
gem 'better_errors'
gem 'binding_of_caller'
gem 'letter_opener'
end
group :test do
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
gem 'chromedriver-helper'
end
My webpacker.yml from app/config/webpack/
default: &default
source_path: app/javascript
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
extensions:
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
development:
<<: *default
compile: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: /node_modules/
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Cache manifest.json for performance
cache_manifest: true
My application.html.erb from app/views/layouts
<%= javascript_pack_tag 'application', 'data-turbolinks-eval': false, defer: true %>
<%= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload', defer: true %>
For me the problem lied in application.js. After creating a brand new Ruby on Rails app my application.js header looked like this:
Before
//= require turbolinks
//= require_tree .
The //=require turbolinks seemed to be causing the problem because I never installed turbolinks or anything of the sort. Removing this line fixed the issue for me:
After
//= require_tree .

Rails + Webpack: Errno::EPERM at / (Operation Not Permitted)

I am trying to run a rails app that uses react and webpacker. All of the node_modules are installed through yarn.
When I boot up the local server using foreman, I get the error:
Errno::EPERM - Operation not permitted - /private/var/db/ConfigurationProfiles/Store:
yarn.lock:
"#rails/webpacker#3.4":
version "3.4.3"
resolved "https://registry.yarnpkg.com/#rails/webpacker/-/webpacker-3.4.3.tgz#496a5d49bea8856db20b212d2727a4b43b281dd9"
dependencies:
babel-core "^6.26.0"
babel-loader "^7.1.2"
babel-plugin-syntax-dynamic-import "^6.18.0"
babel-plugin-transform-class-properties "^6.24.1"
babel-plugin-transform-object-rest-spread "^6.26.0"
babel-polyfill "^6.26.0"
babel-preset-env "^1.6.1"
case-sensitive-paths-webpack-plugin "^2.1.1"
compression-webpack-plugin "^1.1.10"
css-loader "^0.28.9"
extract-text-webpack-plugin "^3.0.2"
file-loader "^1.1.6"
glob "^7.1.2"
js-yaml "^3.10.0"
node-sass "^4.7.2"
path-complete-extname "^1.0.0"
postcss-cssnext "^3.1.0"
postcss-import "^11.0.0"
postcss-loader "^2.1.0"
sass-loader "^6.0.6"
style-loader "^0.20.1"
uglifyjs-webpack-plugin "^1.1.8"
webpack "^3.10.0"
webpack-manifest-plugin "^1.3.2"
Package.json:
{
"dependencies": {
"#rails/webpacker": "3.4",
"babel-preset-react": "^6.24.1",
"prop-types": "^15.6.1",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-on-rails": "11.0.2",
"react_ujs": "^2.4.4",
"wallet-address-validator": "^0.1.7"
},
"devDependencies": {
"webpack-dev-server": "2.11.2"
}
}
Gemfile:
source 'https://rubygems.org'
ruby "2.5.0"
gem 'active_model_otp', "~> 1.2"
gem "active_model_serializers", "~> 0.10"
gem 'attr_encrypted', "~> 3.1"
gem 'bcrypt', "~> 3.1"
gem 'bootsnap', "~> 1.1", require: false
gem 'bulma-rails', "~> 0.6"
gem 'devise', "~> 4.4"
gem 'faker', "~> 1.8"
gem 'fast_jsonapi', "~> 1.0"
gem 'font-awesome-sass', '~> 4.0'
gem 'foreman', "~> 0.64"
gem 'hashie', "~> 3.5"
gem 'httparty', "~> 0.16"
gem 'jquery-rails', "~> 4.3"
gem 'mini_racer', platforms: :ruby
gem 'omniauth-google-oauth2', "~> 0.5"
gem 'pg', "~> 1.0"
gem 'puma', "~> 3.11"
gem 'pundit', "~> 1.1"
gem 'rails', '~> 5.2.0'
gem 'rails_admin'
gem "react_on_rails", "11.0.0"
gem 'rqrcode', "~> 0.10"
gem 'sass-rails', "~> 5.0"
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
gem 'uglifier', "~> 4.1"
gem "webpacker", "~> 3.4"
group :development, :test do
gem 'better_errors', "~> 2.4"
gem 'binding_of_caller', "~> 0.8"
gem 'bullet', "~> 5.7"
gem 'byebug', "~> 10.0"
gem 'listen'
gem 'letter_opener', "~> 1.6"
gem 'meta_request', "~> 0.5"
gem 'spring', "~> 2.0"
gem 'spring-commands-rspec', "~> 1.0"
gem 'web-console', "~> 3.5"
end
group :test do
gem 'factory_bot_rails', "~> 4.8"
end
config/webpacker.yml:
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: app/javascript
source_entry_path: packs
public_output_path: packs
cache_path: tmp/cache/webpacker
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: ['']
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
extensions:
- .jsx
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg 
development:
<<: *default
compile: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: /node_modules/
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Cache manifest.json for performance
cache_manifest: true
bin/webpack:
#!/usr/bin/env ruby
ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development"
ENV["NODE_ENV"] ||= ENV["NODE_ENV"] || "development"
require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)
require "rubygems"
require "bundler/setup"
require "webpacker"
require "webpacker/webpack_runner"
Webpacker::WebpackRunner.run(ARGV)
bin/yarn:
#!/usr/bin/env ruby
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
begin
exec "yarnpkg", *ARGV
rescue Errno::ENOENT
$stderr.puts "Yarn executable was not detected in the system."
$stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
exit 1
end
end
app/javascripts/application.js and app/javascripts/server_rendering.js
var componentRequireContext = require.context("components", true)
var ReactRailsUJS = require("react_ujs")
ReactRailsUJS.useContext(componentRequireContext)
The application hangs up at this line:
<%= javascript_pack_tag 'application' %>
I figured it was a file system issue so I reinstalled macos thinking I might have screwed up permissions with something. I have no idea what is going on.
Just hit the same thing. If you take a look at the stack trace, you'll see it's choking here:
files = Dir[*default_watched_paths, *watched_paths].reject { |f| File.directory?(f) }
The culprit is in webpacker.yml - you'll need to change resolved_paths: [''] to resolved_paths: [] and your problem should be solved :)

Why am I getting *unmatched OUTDENT* in this haml template in Rails 4.2 application?

I've been playing with react-rails gem and so I made a sample application with haml. When I do rails s and go to my sample route, I see the attached error coming from application.html.haml, the standard layout/application.html.haml view in Rails 4.2. If I remove stylesheet_link_tag and javascript_include_tag the Rails view renders fine. What could be causing it? Below are the relevant files. There is also a sample.coffee file but I can't imagine that has anything to do with it since as soon as I remove the *_tag helpers the Rails view renders without error.
application.js.coffee
# 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 react
#= require react_ujs
#= require components
#= require_tree .
application.html.haml
!!!
%html
%head
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
%title SampleApp
= stylesheet_link_tag 'application', media: 'all'
= javascript_include_tag 'application'
= csrf_meta_tags
%body
= yield
application.css
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 4.2.5'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# 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/rails/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
# 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
# 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
gem 'react-rails', '~> 1.6.0'
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
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 'httparty'
gem 'haml-rails'
gem 'annotate'
gem 'figaro'
gem 'pundit'
gem 'lol_dba', require: false
gem 'foreman'
gem 'newrelic_rpm'
group :development do
gem 'sextant'
gem 'awesome_print', require: false
gem 'hirb', require: false
gem 'bullet'
gem 'flog', require: false
gem 'flay', require: false
gem 'reek', require: false
gem 'derailed'
gem 'stackprof'
gem 'sandi_meter'
gem 'rubocop', require: false
end
group :development, :test do
gem 'spring-commands-rspec'
gem 'rspec-rails'
gem 'guard-rspec'
gem 'pry'
end
group :test do
gem 'factory_girl_rails'
gem 'capybara'
gem 'database_cleaner'
gem 'launchy'
gem 'codeclimate-test-reporter', require: nil
gem 'shoulda-matchers', require: false
end
group :production, :staging do
gem 'rails_12factor'
gem 'puma'
end

Deploy masonry in Heroku

Good day,
I made an app with masonry and js.coffee to make something like "pins" in my app, but when I deploy to Heroku don't work like suppose to do.
This is my gem file
source 'https://rubygems.org'
ruby '2.1.4'
gem 'binding_of_caller'
gem 'masonry-rails', '~> 0.2.0'
gem 'haml'
gem 'high_voltage', '~> 2.3.0'
gem 'activevalidators'
gem 'paperclip', github: 'thoughtbot/paperclip'
gem 'simple_form', '~>3.0.2'
gem 'acts_as_votable'
gem 'bootstrap-sass'
gem 'devise', '~> 3.4.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.1'
# Use sqlite3 as the database for Active Record
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# 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/rails/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'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# 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 :assets do
gem 'therubyracer'
gem 'less-rails'
gem 'twitter-bootstrap-rails'
gem 'libv8'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'sqlite3'
# 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
My application.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 bootstrap
//= require bootstrap-sprockets
//= require masonry/jquery.masonry
//= require turbolinks
//= require_tree .
My js.coffee to show pins
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
$ ->
$('#pins').imagesLoaded ->
$('#pins').masonry
itemSelector: '.box'
isFitWidth: true
My index for pins
- content_for :board do
= javascript_include_tag 'application', 'data-turbolinks-track' => true
#pins.transitions-enabled
- #pins.each do |pin|
.box.panel.panel-default
= link_to (image_tag pin.image.url), pin
%h2
= link_to pin.title, pin
%p.user
Ofertado por
= pin.user.name
%p.price
$
= pin.price
Am I doing something wrong?
If it works well under development and won't work upon deployment in heroku, you might have mistakenly configured your database.yml under config.
production:
adapter: postgresql
encoding: utf8
database: (copy database name from your heroku database info)
username: (copy username from your heroku database info)
password: TV9ncj-HR1FqNFihKm6zlsHhxU
host: (copy host from your heroku database info)
sslmode: require
and don't forget to do the rake db:migrate
if this is not the answer you were looking for, this might still be a little useful for you, if not now, maybe in the near future as you go along with your code.

Resources