Skip to content

Instantly share code, notes, and snippets.

View 123ish's full-sized avatar

123ish LLC 123ish

View GitHub Profile
@123ish
123ish / add_virtual_column_index_to_ahoy_events.rb
Created November 25, 2020 02:20 — forked from kevinhq/add_virtual_column_index_to_ahoy_events.rb
Virtual Column Index for ahoy_events table
class AddVirtualColumnIndexToAhoyEvents < ActiveRecord::Migration[6.0]
def up
ActiveRecord::Base.connection.execute (
'ALTER TABLE ahoy_events ADD properties_id INT AS (JSON_UNQUOTE(properties->"$.id")) STORED;'
)
ActiveRecord::Base.connection.execute (
'ALTER TABLE ahoy_events ADD INDEX (properties_id);'
)
end
def down
@123ish
123ish / application.html.erb
Created August 15, 2020 18:03 — forked from kevinhq/application.html.erb
Step-by-Step guide on how to move from Sprockets to Webpacker - application.html.erb
<%# app/views/layouts/application.html.erb %>
<!DOCTYPE html>
<html>
<head>
<!-- add this new application.js -->
<%= javascript_pack_tag 'application' %>
</head>
<body>
<%= yield %>
</body>
@123ish
123ish / application.js
Created August 15, 2020 18:03 — forked from kevinhq/application.js
Step-by-Step guide on how to move from Sprockets to Webpacker - updated application.js
/* app/javascript/packs/application.js */
require("@rails/ujs").start();
require("@rails/activestorage").start();
require("packs/example1");
require("packs/example2");
require("packs/example3");
@123ish
123ish / example2.js
Created August 15, 2020 18:03 — forked from kevinhq/example2.js
Step-by-Step guide on how to move from Sprockets to Webpacker - packs/example2.js
/* app/javascript/packs/example2.js */
// to call example1 var, you need:
import example1 from './example1';
@123ish
123ish / example1.js
Created August 15, 2020 18:02 — forked from kevinhq/example1.js
Step-by-Step guide on how to move from Sprockets to Webpacker - packs/example1.js
/* app/javascript/packs/example1.js */
var example1 = function doSomething() {
// Your codes here
}
export default example1;
@123ish
123ish / application.js
Created August 15, 2020 18:02 — forked from kevinhq/application.js
Step-by-Step guide on how to move from Sprockets to Webpacker - application.js
/* app/javascript/packs/application.js */
require("@rails/ujs").start();
require("@rails/activestorage").start();
@123ish
123ish / production.js
Created August 15, 2020 18:01 — forked from kevinhq/production.js
Step-by-Step guide on how to move from Sprockets to Webpacker - production.js
// config/webpack/production.js
process.env.NODE_ENV = 'production';
const environment = require('./environment');
module.exports = environment.toWebpackConfig();
@123ish
123ish / erb.js
Created August 15, 2020 18:01 — forked from kevinhq/erb.js
Step-by-Step guide on how to move from Sprockets to Webpacker - erb.js
// config/webpack/loaders/erb.js
module.exports = {
test: /\.erb$/,
enforce: 'pre',
exclude: /node_modules/,
use: [{
loader: 'rails-erb-loader',
options: {
runner: (/^win/.test(process.platform) ? 'ruby ' : '') + 'bin/rails runner'
}
@123ish
123ish / custom_loader.js
Created August 15, 2020 18:00 — forked from kevinhq/custom_loader.js
Step-by-Step guide on how to move from Sprockets to Webpacker - custom_loader.js
// config/webpack/loaders/custom_loaders.js
module.exports = {
test: /\.ya?ml$/,
loaders: ['json-loader', 'yaml-loader']
};
@123ish
123ish / Gemfile
Created August 15, 2020 17:59 — forked from kevinhq/Gemfile
Step-by-Step guide on how to move from Sprockets to Webpacker - Gemfile
gem "webpacker"