rs-activeadmin-searchable_select 4.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. data/.actrc +20 -0
  3. data/.claude/commands/fix-tests.md +203 -0
  4. data/.github/workflows/ci.yml +170 -0
  5. data/.github/workflows/npm-publish.yml +47 -0
  6. data/.gitignore +27 -0
  7. data/.npmignore +58 -0
  8. data/.rspec +2 -0
  9. data/.rubocop.yml +67 -0
  10. data/.yardopts +2 -0
  11. data/AGENTS.md +39 -0
  12. data/Appraisals +15 -0
  13. data/CHANGELOG.md +24 -0
  14. data/CLAUDE.md +104 -0
  15. data/Gemfile +11 -0
  16. data/Gemfile.lock +366 -0
  17. data/LICENSE.txt +25 -0
  18. data/README.md +439 -0
  19. data/Rakefile +4 -0
  20. data/bin/rspec +17 -0
  21. data/config/database.yml +16 -0
  22. data/config.ru +28 -0
  23. data/docs/activeadmin-4-detailed-reference.md +932 -0
  24. data/docs/activeadmin-4-gem-migration-guide.md +313 -0
  25. data/docs/combustion.md +213 -0
  26. data/docs/for-next-session.md +199 -0
  27. data/docs/guide-update-your-app.md +213 -0
  28. data/docs/propshaft-readme.md +121 -0
  29. data/docs/propshaft-upgrade.md +267 -0
  30. data/docs/rails-7-asset-pipeline.md +279 -0
  31. data/docs/setup-activeadmin-app.md +552 -0
  32. data/docs/setup-activeadmin-gem.md +535 -0
  33. data/docs/upload-system.md +225 -0
  34. data/gemfiles/rails_7.x_active_admin_4.x.gemfile +11 -0
  35. data/gemfiles/rails_7.x_active_admin_4.x.gemfile.lock +371 -0
  36. data/gemfiles/rails_8.x_active_admin_4.x.gemfile +11 -0
  37. data/gemfiles/rails_8.x_active_admin_4.x.gemfile.lock +366 -0
  38. data/lefthook.yml +17 -0
  39. data/lib/activeadmin/inputs/filters/searchable_select_input.rb +13 -0
  40. data/lib/activeadmin/inputs/searchable_select_input.rb +11 -0
  41. data/lib/activeadmin/searchable_select/engine.rb +17 -0
  42. data/lib/activeadmin/searchable_select/option_collection.rb +119 -0
  43. data/lib/activeadmin/searchable_select/resource_dsl_extension.rb +56 -0
  44. data/lib/activeadmin/searchable_select/resource_extension.rb +10 -0
  45. data/lib/activeadmin/searchable_select/select_input_extension.rb +159 -0
  46. data/lib/activeadmin/searchable_select/version.rb +5 -0
  47. data/lib/activeadmin/searchable_select.rb +20 -0
  48. data/lib/activeadmin-searchable_select.rb +4 -0
  49. data/lib/generators/active_admin/searchable_select/install/install_generator.rb +217 -0
  50. data/package-lock.json +18 -0
  51. data/package.json +45 -0
  52. data/rs-activeadmin-searchable_select.gemspec +38 -0
  53. data/sonar-project.properties +25 -0
  54. data/spec/features/ajax_params_spec.rb +31 -0
  55. data/spec/features/end_to_end_spec.rb +227 -0
  56. data/spec/features/filter_input_spec.rb +137 -0
  57. data/spec/features/form_input_spec.rb +122 -0
  58. data/spec/features/inline_ajax_setting_spec.rb +26 -0
  59. data/spec/features/input_errors_spec.rb +76 -0
  60. data/spec/features/input_html_options_spec.rb +30 -0
  61. data/spec/features/options_dsl_spec.rb +220 -0
  62. data/spec/features/production_build_spec.rb +108 -0
  63. data/spec/internal/app/admin/categories.rb +26 -0
  64. data/spec/internal/app/admin/dashboard.rb +29 -0
  65. data/spec/internal/app/admin/option_types.rb +19 -0
  66. data/spec/internal/app/admin/option_values.rb +30 -0
  67. data/spec/internal/app/admin/posts.rb +27 -0
  68. data/spec/internal/app/admin/products.rb +22 -0
  69. data/spec/internal/app/admin/rgb_colors.rb +25 -0
  70. data/spec/internal/app/admin/tag_names.rb +21 -0
  71. data/spec/internal/app/admin/test_ajax_params_category.rb +10 -0
  72. data/spec/internal/app/admin/test_ajax_params_post.rb +20 -0
  73. data/spec/internal/app/admin/test_form_post_class.rb +7 -0
  74. data/spec/internal/app/admin/test_form_post_custom.rb +11 -0
  75. data/spec/internal/app/admin/test_form_post_resource.rb +11 -0
  76. data/spec/internal/app/admin/test_form_post_resource_custom.rb +12 -0
  77. data/spec/internal/app/admin/test_inline_ajax_post.rb +9 -0
  78. data/spec/internal/app/admin/test_input_html_post.rb +11 -0
  79. data/spec/internal/app/admin/test_posts_display_text.rb +9 -0
  80. data/spec/internal/app/admin/test_posts_filter.rb +9 -0
  81. data/spec/internal/app/admin/test_posts_named.rb +9 -0
  82. data/spec/internal/app/admin/test_posts_pagination.rb +9 -0
  83. data/spec/internal/app/admin/test_posts_payload_lambda.rb +11 -0
  84. data/spec/internal/app/admin/test_posts_payload_proc.rb +9 -0
  85. data/spec/internal/app/admin/test_posts_scope_lambda.rb +8 -0
  86. data/spec/internal/app/admin/test_posts_scope_params.rb +8 -0
  87. data/spec/internal/app/admin/test_posts_scope_user.rb +8 -0
  88. data/spec/internal/app/admin/test_posts_text_attr.rb +5 -0
  89. data/spec/internal/app/admin/users.rb +23 -0
  90. data/spec/internal/app/admin/variants.rb +31 -0
  91. data/spec/internal/app/assets/config/manifest.js +1 -0
  92. data/spec/internal/app/assets/javascripts/active_admin.js +2 -0
  93. data/spec/internal/app/assets/javascripts/searchable_select_test.js +2 -0
  94. data/spec/internal/app/controllers/application_controller.rb +5 -0
  95. data/spec/internal/app/css/active_admin_source.css +81 -0
  96. data/spec/internal/app/js/active_admin.js +17 -0
  97. data/spec/internal/app/models/article.rb +12 -0
  98. data/spec/internal/app/models/category.rb +12 -0
  99. data/spec/internal/app/models/internal/tag_name.rb +14 -0
  100. data/spec/internal/app/models/internal_tag_name.rb +11 -0
  101. data/spec/internal/app/models/option_type.rb +12 -0
  102. data/spec/internal/app/models/option_value.rb +4 -0
  103. data/spec/internal/app/models/post.rb +15 -0
  104. data/spec/internal/app/models/product.rb +12 -0
  105. data/spec/internal/app/models/rgb_color.rb +16 -0
  106. data/spec/internal/app/models/user.rb +12 -0
  107. data/spec/internal/app/models/variant.rb +12 -0
  108. data/spec/internal/build_activeadmin_css.js +115 -0
  109. data/spec/internal/config/database.yml +7 -0
  110. data/spec/internal/config/environment.rb +48 -0
  111. data/spec/internal/config/initializers/active_admin.rb +53 -0
  112. data/spec/internal/config/initializers/assets.rb +9 -0
  113. data/spec/internal/config/initializers/searchable_select.rb +6 -0
  114. data/spec/internal/config/routes.rb +4 -0
  115. data/spec/internal/config.ru +4 -0
  116. data/spec/internal/db/schema.rb +63 -0
  117. data/spec/internal/db/seeds.rb +88 -0
  118. data/spec/internal/esbuild.config.js +30 -0
  119. data/spec/internal/inject-jquery.js +4 -0
  120. data/spec/internal/log/.gitignore +1 -0
  121. data/spec/internal/package/LICENSE.txt +25 -0
  122. data/spec/internal/package/README.md +439 -0
  123. data/spec/internal/package/package.json +45 -0
  124. data/spec/internal/package/src/index.js +1 -0
  125. data/spec/internal/package/src/searchable_select/init.js +1 -0
  126. data/spec/internal/package/src/searchable_select.css +1 -0
  127. data/spec/internal/package/src/searchable_select.scss +1 -0
  128. data/spec/internal/package-lock.json +1385 -0
  129. data/spec/internal/package.json +26 -0
  130. data/spec/internal/public/favicon.ico +0 -0
  131. data/spec/internal/spec/internal/app/css/active_admin_source.css +38 -0
  132. data/spec/internal/spec/internal/log/test.log +0 -0
  133. data/spec/internal/tailwind-active_admin.config.js +53 -0
  134. data/spec/rails_helper.rb +86 -0
  135. data/spec/spec_helper.rb +137 -0
  136. data/spec/support/active_admin_helpers.rb +17 -0
  137. data/spec/support/capybara.rb +8 -0
  138. data/spec/support/models.rb +88 -0
  139. data/spec/support/pluck_polyfill.rb +12 -0
  140. data/spec/support/reset_settings.rb +5 -0
  141. data/src/index.js +77 -0
  142. data/src/searchable_select/init.js +58 -0
  143. data/src/searchable_select.css +5 -0
  144. data/src/searchable_select.css.map +1 -0
  145. metadata +405 -0
@@ -0,0 +1,199 @@
1
+ # Session Continuation Notes - ActiveAdmin Gems Standardization
2
+
3
+ ## Current Status
4
+ Working on standardizing two ActiveAdmin gems:
5
+ - `/data/activeadmin_trumbowyg` (rs-activeadmin_trumbowyg) - **FULLY WORKING v4.0.4** ✅
6
+ - Fixed critical CSS bundling issue using Tailwind CLI
7
+ - All CSS loading tests passing (4/4) ✅
8
+ - Updated tests to check for ActiveAdmin 4's actual HTML structure
9
+ - Fixed CI workflow to build and extract npm package (avoids vendor symlink issues)
10
+ - `/data/activeadmin-searchable_select` (rs-activeadmin-searchable_select) - Needs updates ⚠️
11
+
12
+ ## Completed Tasks
13
+ 1. ✅ Fixed CI failures for both gems
14
+ 2. ✅ Standardized NPM package structure
15
+ 3. ✅ Forked both gems with new names (rs- prefix)
16
+ 4. ✅ Published NPM packages:
17
+ - `@rocket-sensei/activeadmin_trumbowyg@4.0.4`
18
+ - `@rocket-sensei/activeadmin-searchable_select@4.0.5`
19
+ 5. ✅ Updated documentation for ActiveAdmin 4 and Propshaft
20
+ 6. ✅ Both gems support ActiveAdmin 4.0.0.beta only
21
+ 7. ✅ Fixed jQuery loading issues with proper module exports
22
+ 8. ✅ Set up proper NPM package imports instead of esbuild aliases
23
+ 9. ✅ Created NPM scripts to copy both icons.svg and CSS from trumbowyg package
24
+ 10. ✅ Added generated assets to .gitignore
25
+ 11. ✅ Removed Tailwind dependencies and simplified CSS build
26
+ 12. ✅ Fixed assets to be served locally via Propshaft (no CDN)
27
+ 13. ✅ **FIXED CSS BUILD** - Now using Tailwind CLI with ActiveAdmin plugin
28
+ - Created `tailwind-active_admin.config.js` based on production app `/data/rslogin-ui/`
29
+ - Created `build_activeadmin_css.js` to properly bundle CSS
30
+ - CSS now includes: Tailwind base + Trumbowyg vendor CSS + custom styles
31
+ - Build command: `npm run build:css:activeadmin`
32
+ - Updated CSS loading tests to check for ActiveAdmin 4's actual HTML structure
33
+ - All CSS loading tests now passing (was checking for old `#header` instead of new Tailwind classes)
34
+ 14. ✅ **FIXED CI WORKFLOW** - Build and extract npm package to avoid vendor symlink issues
35
+ - Build npm package with `npm pack`
36
+ - Extract to `/tmp/npm-package`
37
+ - Install from extracted package instead of `file:../..`
38
+ - Completely avoids RSpec discovering vendor/bundle specs through symlinks
39
+
40
+ ## NEXT SESSION: Fix activeadmin-searchable_select
41
+
42
+ ### Main Issues to Fix
43
+ 1. **Test app needs Propshaft setup** (currently partially configured)
44
+ - File: `spec/internal/config/environment.rb` - Changed to use `:propshaft` ✅
45
+ - Still needs proper asset loading configuration
46
+
47
+ 2. **Test failures** - 1 test failing:
48
+ ```
49
+ spec/features/inline_ajax_setting_spec.rb:25
50
+ # inline_ajax_options setting when ajax option set to true renders all options statically
51
+ ```
52
+ - Issue: JavaScript not loading properly in test environment
53
+ - The helper in `spec/internal/config/initializers/active_admin.rb` loads from `src/searchable_select/init.js`
54
+
55
+ 3. **Module namespace issues** (partially fixed):
56
+ - Fixed in: `lib/activeadmin/inputs/searchable_select_input.rb`
57
+ - Fixed in: `lib/activeadmin/inputs/filters/searchable_select_input.rb`
58
+ - Changed from `SearchableSelect::SelectInputExtension` to `ActiveAdmin::SearchableSelect::SelectInputExtension`
59
+
60
+ ### Test App Configuration Needed
61
+
62
+ #### Current searchable_select test app structure:
63
+ ```
64
+ spec/internal/
65
+ ├── app/
66
+ │ └── assets/
67
+ │ ├── builds/.keep (created)
68
+ │ └── javascripts/
69
+ │ ├── active_admin.js (Sprockets syntax - needs update)
70
+ │ └── searchable_select_test.js (placeholder)
71
+ ├── config/
72
+ │ ├── environment.rb (updated to use Propshaft ✅)
73
+ │ └── initializers/
74
+ │ ├── active_admin.rb (loads JS via helper - needs review)
75
+ │ └── assets.rb (Sprockets config - needs update)
76
+ └── (no package.json, no esbuild config)
77
+ ```
78
+
79
+ #### CI Workflow Fix for searchable_select
80
+ **CRITICAL**: Must use same approach as trumbowyg to avoid vendor/bundle symlink issues:
81
+ 1. Build npm package with `npm pack`
82
+ 2. Extract to `/tmp/npm-package`
83
+ 3. Install from extracted package in test app
84
+ 4. See: `/data/activeadmin_trumbowyg/.github/workflows/ci.yml` lines 68-87
85
+
86
+ ### What searchable_select needs (adapt from trumbowyg):
87
+ 1. **esbuild.config.js** - Create based on `/data/activeadmin_trumbowyg/spec/internal/esbuild.config.js`
88
+ - Change alias from `'activeadmin_trumbowyg'` to `'activeadmin-searchable_select'`
89
+ - Point to `'../../src/index.js'`
90
+
91
+ 2. **package.json** - Create based on `/data/activeadmin_trumbowyg/spec/internal/package.json`
92
+ - Keep: esbuild, @activeadmin/activeadmin, jquery
93
+ - Add: select2 (instead of trumbowyg)
94
+ - Remove: trumbowyg, tailwindcss, @tailwindcss/forms
95
+
96
+ 3. **inject-jquery.js** - Copy `/data/activeadmin_trumbowyg/spec/internal/inject-jquery.js` as-is
97
+
98
+ 4. **app/js/active_admin.js** - Create based on `/data/activeadmin_trumbowyg/spec/internal/app/js/active_admin.js`
99
+ - Import activeadmin-searchable_select instead of activeadmin_trumbowyg
100
+
101
+ ### Security Issues Fixed in trumbowyg
102
+
103
+ 1. **Removed from trumbowyg** (unnecessary complexity):
104
+ - ✅ `spec/internal/build_css.js` - Removed
105
+ - ✅ `spec/internal/tailwind.config.mjs` - Removed
106
+ - ✅ Simplified to just copy CSS from npm package
107
+
108
+ ### Latest Fixes in trumbowyg (Session 2)
109
+
110
+ 1. **Icon serving fixed**:
111
+ - ✅ Icons now copied to both `app/assets/builds/` and `public/`
112
+ - ✅ Configurable SVG path via `window.TRUMBOWYG_SVG_PATH`
113
+ - ✅ Works with Propshaft in production and development
114
+
115
+ 2. **Documentation created**:
116
+ - ✅ Migration guide at `docs/guide-update-your-app.md`
117
+ - ✅ README updated with correct paths and instructions
118
+ - ✅ Clear Propshaft configuration documented
119
+
120
+ 2. **Docker setup** (low priority):
121
+ - `/data/activeadmin_trumbowyg/extra/` directory
122
+ - Safe but consider removing if not needed
123
+
124
+ ### Key Files to Reference from activeadmin_trumbowyg
125
+
126
+ #### Working test app files to use as templates:
127
+ - `/data/activeadmin_trumbowyg/spec/internal/esbuild.config.js` - Working esbuild config
128
+ - `/data/activeadmin_trumbowyg/spec/internal/package.json` - Package dependencies for test app
129
+ - `/data/activeadmin_trumbowyg/spec/internal/inject-jquery.js` - jQuery injection helper
130
+ - `/data/activeadmin_trumbowyg/spec/internal/app/js/active_admin.js` - Working JS entry point
131
+ - **NEW**: `/data/activeadmin_trumbowyg/spec/internal/tailwind-active_admin.config.js` - Tailwind config with ActiveAdmin plugin
132
+ - **NEW**: `/data/activeadmin_trumbowyg/spec/internal/build_activeadmin_css.js` - CSS build script
133
+ - `/data/activeadmin_trumbowyg/spec/rails_helper.rb` - Test configuration
134
+ - `/data/activeadmin_trumbowyg/spec/internal/config/initializers/active_admin.rb` - ActiveAdmin config
135
+ - `/data/activeadmin_trumbowyg/spec/internal/config/initializers/assets.rb` - Asset configuration
136
+ - `/data/activeadmin_trumbowyg/spec/internal/config/initializers/trumbowyg.rb` - Gem-specific config
137
+
138
+ #### Files REMOVED from trumbowyg (security warnings):
139
+ - ✅ `/data/activeadmin_trumbowyg/spec/internal/build_css.js` - Deleted
140
+ - ✅ `/data/activeadmin_trumbowyg/spec/internal/tailwind.config.mjs` - Deleted
141
+
142
+ #### Broken test file from searchable_select:
143
+ - `spec/internal/config/initializers/active_admin.rb` (lines 56-63):
144
+ ```ruby
145
+ def add_searchable_select_js(content)
146
+ content << '<script type="text/javascript">'
147
+ js_file_path = File.expand_path(
148
+ '../../../../src/searchable_select/init.js', __dir__
149
+ )
150
+ content << File.read(js_file_path)
151
+ content << '</script>'
152
+ end
153
+ ```
154
+
155
+ ### Testing Commands
156
+ ```bash
157
+ # Test searchable_select
158
+ cd /data/activeadmin-searchable_select
159
+ bundle exec rspec spec/features/inline_ajax_setting_spec.rb
160
+
161
+ # Test trumbowyg (all passing)
162
+ cd /data/activeadmin_trumbowyg
163
+ bundle exec rspec --fail-fast
164
+ ```
165
+
166
+ ### Key Decisions Made
167
+ 1. **No Sprockets support** - Only Propshaft for ActiveAdmin 4
168
+ 2. **Minimal test app setup** - Remove Tailwind/CSS build complexity
169
+ 3. **Standardize on esbuild** for JavaScript in test apps
170
+ 4. **Both gems must have identical structure** for maintainability
171
+
172
+ ### Important Notes
173
+ - The `src/` directory in both gems contains the actual JavaScript code
174
+ - Test apps should use the actual NPM package (`@rocket-sensei/activeadmin_trumbowyg`) via `file:../..` in package.json
175
+ - Icons.svg must be copied from node_modules using NPM scripts (not committed to repo)
176
+ - The gem exports proper ES modules with `setupAutoInit()` function
177
+ - jQuery must be made global BEFORE importing Trumbowyg
178
+ - Both gems already have proper NPM package configuration
179
+ - The Ruby gem parts are working, just need test app fixes
180
+
181
+ ### Key Changes Made to activeadmin_trumbowyg
182
+ 1. **Module Structure**: Changed from auto-initializing to exporting functions (`setupAutoInit`)
183
+ 2. **Package Reference**: Test app uses `"@rocket-sensei/activeadmin_trumbowyg": "file:../.."`
184
+ 3. **Icon Handling**: Icons copied via NPM script, not stored in repo
185
+ 4. **Build Process**: `npm run build` now includes `copy:icons` step
186
+
187
+ ### Version Info
188
+ - activeadmin_trumbowyg: **4.0.4 FULLY WORKING** ✅
189
+ - Gem: `rs-activeadmin_trumbowyg`
190
+ - NPM: `@rocket-sensei/activeadmin_trumbowyg`
191
+ - All CSS loading tests passing (4/4)
192
+ - Icons served correctly from `/trumbowyg/icons.svg`
193
+ - CSS properly bundled with Tailwind + ActiveAdmin plugin + Trumbowyg
194
+ - Documentation updated
195
+ - CI workflow fixed to build/extract npm package (avoids vendor symlinks)
196
+ - activeadmin-searchable_select: 4.0.5 (needs similar updates)
197
+ - Gem: `rs-activeadmin-searchable_select`
198
+ - NPM: `@rocket-sensei/activeadmin-searchable_select`
199
+ - Needs: Tailwind CSS build, CI workflow fix, test app setup
@@ -0,0 +1,213 @@
1
+ # Migration Guide: Updating to rs-activeadmin-searchable_select
2
+
3
+ This guide will help you migrate from the original `activeadmin-searchable_select` gem to our forked and updated version `rs-activeadmin-searchable_select`.
4
+
5
+ ## Why Update?
6
+
7
+ Our fork provides:
8
+ - ✅ Full ActiveAdmin 4.0 support
9
+ - ✅ Rails 8 and Propshaft compatibility
10
+ - ✅ Modern JavaScript bundler support (esbuild/webpack/importmap)
11
+ - ✅ Proper NPM package distribution under @rocket-sensei scope
12
+ - ✅ Fixed production build issues with select2
13
+ - ✅ Improved test suite with static ActiveAdmin registrations
14
+ - ✅ Active maintenance and support
15
+
16
+ ## Migration Steps
17
+
18
+ ### Step 1: Update your Gemfile
19
+
20
+ Replace the old gem with our fork:
21
+
22
+ ```ruby
23
+ # Remove this:
24
+ # gem 'activeadmin-searchable_select'
25
+
26
+ # Add this:
27
+ gem 'rs-activeadmin-searchable_select', '~> 4.0'
28
+
29
+ # For Rails 7, also ensure you have Propshaft:
30
+ gem 'propshaft' # Rails 8 includes this by default
31
+ ```
32
+
33
+ Then run:
34
+ ```bash
35
+ bundle install
36
+ ```
37
+
38
+ ### Step 2: Update JavaScript Dependencies
39
+
40
+ Remove old packages and install the new ones:
41
+
42
+ ```bash
43
+ # Remove old packages if present
44
+ npm uninstall @codevise/activeadmin-searchable_select
45
+
46
+ # Install new packages
47
+ npm install @rocket-sensei/activeadmin-searchable_select jquery select2
48
+ ```
49
+
50
+ ### Step 3: Update JavaScript Imports
51
+
52
+ Update your `app/javascript/active_admin.js`:
53
+
54
+ ```javascript
55
+ import "@activeadmin/activeadmin";
56
+ import $ from 'jquery';
57
+ import select2 from 'select2';
58
+
59
+ // Critical: Initialize select2 on jQuery (fixes production builds)
60
+ select2($);
61
+ window.$ = window.jQuery = $;
62
+
63
+ // Import the searchable select functionality
64
+ import '@rocket-sensei/activeadmin-searchable_select';
65
+ ```
66
+
67
+ ### Step 4: Add Select2 CSS
68
+
69
+ Add to your ActiveAdmin stylesheet (`app/assets/stylesheets/active_admin.css` or `.scss`):
70
+
71
+ ```css
72
+ /* Import Select2 styles */
73
+ @import url('https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css');
74
+
75
+ /* Optional: Custom styling for searchable selects */
76
+ .searchable-select-input {
77
+ width: 100%;
78
+ }
79
+
80
+ /* Fix for ActiveAdmin form layout */
81
+ .select2-container {
82
+ min-width: 50%;
83
+ }
84
+ ```
85
+
86
+ ### Step 5: For Importmap Users
87
+
88
+ If you're using importmap instead of esbuild, add to `config/importmap.rb`:
89
+
90
+ ```ruby
91
+ pin "jquery", to: "https://ga.jspm.io/npm:jquery@3.7.1/dist/jquery.js"
92
+ pin "select2", to: "https://ga.jspm.io/npm:select2@4.1.0-rc.0/dist/js/select2.full.js"
93
+ pin "@rocket-sensei/activeadmin-searchable_select", to: "@rocket-sensei--activeadmin-searchable_select.js"
94
+ ```
95
+
96
+ And update your `app/javascript/active_admin.js`:
97
+
98
+ ```javascript
99
+ import "@activeadmin/activeadmin";
100
+ import jquery from "jquery";
101
+ import select2 from "select2";
102
+
103
+ // Make jQuery available globally
104
+ window.$ = window.jQuery = jquery;
105
+
106
+ // Initialize select2
107
+ select2(jquery);
108
+
109
+ // Import searchable select
110
+ import "@rocket-sensei/activeadmin-searchable_select";
111
+ ```
112
+
113
+ ### Step 6: Update Your ActiveAdmin Resources
114
+
115
+ The API remains the same, but ensure your resources are configured correctly:
116
+
117
+ ```ruby
118
+ ActiveAdmin.register Product do
119
+ # For forms
120
+ form do |f|
121
+ f.inputs do
122
+ f.input :category, as: :searchable_select, ajax: true
123
+ f.input :tags, as: :searchable_select, ajax: true, multiple: true
124
+ end
125
+ f.actions
126
+ end
127
+
128
+ # For filters
129
+ filter :category, as: :searchable_select, ajax: true
130
+ filter :tags, as: :searchable_select, ajax: true, multiple: true
131
+ end
132
+
133
+ # Define searchable select options endpoint
134
+ ActiveAdmin.register Category do
135
+ searchable_select_options(
136
+ scope: Category.all,
137
+ text_attribute: :name
138
+ )
139
+ end
140
+ ```
141
+
142
+ ## Troubleshooting
143
+
144
+ ### "select2 is not a function" Error
145
+
146
+ This usually happens in production when select2 isn't properly initialized. Ensure:
147
+
148
+ 1. jQuery is loaded before select2
149
+ 2. `select2($)` is called to initialize it on jQuery
150
+ 3. jQuery is made globally available with `window.$ = window.jQuery = $`
151
+
152
+ ### Styles Not Loading
153
+
154
+ 1. Verify the Select2 CSS import is in your stylesheet
155
+ 2. Check that your build process includes the stylesheets
156
+ 3. Clear your browser cache and restart Rails server
157
+
158
+ ### Ajax Options Not Loading
159
+
160
+ 1. Ensure `searchable_select_options` is defined in the target resource
161
+ 2. Check browser console for any JavaScript errors
162
+ 3. Verify the AJAX URLs are correct in the network tab
163
+
164
+ ### Multiple Select Not Working
165
+
166
+ Ensure you've added `multiple: true` to both the input and the corresponding association:
167
+
168
+ ```ruby
169
+ # In your model
170
+ has_many :tags
171
+
172
+ # In your ActiveAdmin resource
173
+ f.input :tags, as: :searchable_select, ajax: true, multiple: true
174
+ ```
175
+
176
+ ## Version Compatibility
177
+
178
+ - **Ruby**: >= 3.0
179
+ - **Rails**: >= 7.0 (optimized for Rails 8)
180
+ - **ActiveAdmin**: ~> 4.0.0.beta
181
+ - **Node.js**: >= 18.0
182
+
183
+ ## Differences from Original Gem
184
+
185
+ 1. **NPM Scope**: Package is now `@rocket-sensei/activeadmin-searchable_select`
186
+ 2. **Gem Name**: Gem is now `rs-activeadmin-searchable_select`
187
+ 3. **Better Production Support**: Fixed select2 initialization issues
188
+ 4. **Rails 8 Ready**: Full support for Propshaft and modern Rails
189
+ 5. **Improved Tests**: Static ActiveAdmin registrations for better test isolation
190
+
191
+ ## Need Help?
192
+
193
+ If you encounter issues:
194
+ 1. Check that all JavaScript packages are installed
195
+ 2. Verify your bundler configuration
196
+ 3. Clear browser cache and Rails tmp/cache
197
+ 4. Check browser console for errors
198
+
199
+ For bug reports or questions, please visit:
200
+ https://github.com/glebtv/activeadmin-searchable_select/issues
201
+
202
+ ## Contributing
203
+
204
+ We welcome contributions! Please:
205
+ 1. Fork the repository
206
+ 2. Create a feature branch
207
+ 3. Write tests for your changes
208
+ 4. Ensure all tests pass with `bundle exec rspec`
209
+ 5. Submit a pull request
210
+
211
+ ## License
212
+
213
+ This gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,121 @@
1
+ # Propshaft
2
+
3
+ Propshaft is an asset pipeline library for Rails. It's built for an era where bundling assets to save on HTTP connections is no longer urgent, where JavaScript and CSS are either compiled by dedicated Node.js bundlers or served directly to the browsers, and where increases in bandwidth have made the need for minification less pressing. These factors allow for a dramatically simpler and faster asset pipeline compared to previous options, like [Sprockets](https://github.com/rails/sprockets-rails).
4
+
5
+ So that's what Propshaft doesn't do. Here's what it does provide:
6
+
7
+ 1. **Configurable load path**: You can register directories from multiple places in your app and gems, and reference assets from all of these paths as though they were one.
8
+ 1. **Digest stamping**: All assets in the load path will be copied (or compiled) in a precompilation step for production that also stamps all of them with a digest hash, so you can use long-expiry cache headers for better performance. The digested assets can be referred to through their logical path because the processing leaves a manifest file that provides a way to translate.
9
+ 1. **Development server**: There's no need to precompile the assets in development. You can refer to them via the same asset_path helpers and they'll be served by a development server.
10
+ 1. **Basic compilers**: Propshaft was explicitly not designed to provide full transpiler capabilities. You can get that better elsewhere. But it does offer a simple input->output compiler setup that by default is used to translate `url(asset)` function calls in CSS to `url(digested-asset)` instead and source mapping comments likewise.
11
+
12
+
13
+ ## Installation
14
+
15
+ With Rails 8, Propshaft is the default asset pipeline for new applications. With Rails 7, you can start a new application with propshaft using `rails new myapp -a propshaft`. For existing applications, check the [upgrade guide](https://github.com/rails/propshaft/blob/main/UPGRADING.md) which contains step-by-step instructions.
16
+
17
+ ## Usage
18
+
19
+ Propshaft makes all the assets from all the paths it's been configured with through `config.assets.paths` available for serving and will copy all of them into `public/assets` when precompiling. This is unlike Sprockets, which did not copy over assets that hadn't been explicitly included in one of the bundled assets.
20
+
21
+ You can however exempt directories that have been added through the `config.assets.excluded_paths`. This is useful if you're for example using `app/assets/stylesheets` exclusively as a set of inputs to a compiler like Dart Sass for Rails, and you don't want these input files to be part of the load path. (Remember you need to add full paths, like `Rails.root.join("app/assets/stylesheets")`).
22
+
23
+ These assets can be referenced through their logical path using the normal helpers like `asset_path`, `image_tag`, `javascript_include_tag`, and all the other asset helper tags. These logical references are automatically converted into digest-aware paths in production when `assets:precompile` has been run (through a JSON mapping file found in `public/assets/.manifest.json`).
24
+
25
+ ## Referencing digested assets in CSS and JavaScript
26
+
27
+ Propshaft will automatically convert asset references in CSS to use the digested file names. So `background: url("/bg/pattern.svg")` is converted to `background: url("/assets/bg/pattern-2169cbef.svg")` before the stylesheet is served.
28
+
29
+ For JavaScript, you'll have to manually trigger this transformation by using the `RAILS_ASSET_URL` pseudo-method. It's used like this:
30
+
31
+ ```javascript
32
+ export default class extends Controller {
33
+ init() {
34
+ this.img = RAILS_ASSET_URL("/icons/trash.svg")
35
+ }
36
+ }
37
+ ```
38
+
39
+ That'll turn into:
40
+
41
+ ```javascript
42
+ export default class extends Controller {
43
+ init() {
44
+ this.img = "/assets/icons/trash-54g9cbef.svg"
45
+ }
46
+ }
47
+ ```
48
+
49
+ ## Bypassing the digest step
50
+
51
+ If you need to put multiple files that refer to each other through Propshaft, like a JavaScript file and its source map, you have to digest these files in advance to retain stable file names. Propshaft looks for the specific pattern of `-[digest].digested.js` as the postfix to any asset file as an indication that the file has already been digested.
52
+
53
+ ## Subresource Integrity (SRI)
54
+
55
+ Propshaft supports Subresource Integrity (SRI) to help protect against malicious modifications of assets. SRI allows browsers to verify that resources fetched from CDNs or other sources haven't been tampered with by checking cryptographic hashes.
56
+
57
+ ### Enabling SRI
58
+
59
+ To enable SRI support, configure the hash algorithm in your Rails application:
60
+
61
+ ```ruby
62
+ config.assets.integrity_hash_algorithm = "sha384"
63
+ ```
64
+
65
+ Valid hash algorithms include:
66
+ - `"sha256"` - SHA-256 (most common)
67
+ - `"sha384"` - SHA-384 (recommended for enhanced security)
68
+ - `"sha512"` - SHA-512 (strongest)
69
+
70
+ ### Using SRI in your views
71
+
72
+ Once configured, you can enable SRI by passing the `integrity: true` option to asset helpers:
73
+
74
+ ```erb
75
+ <%= stylesheet_link_tag "application", integrity: true %>
76
+ <%= javascript_include_tag "application", integrity: true %>
77
+ ```
78
+
79
+ This generates HTML with integrity hashes:
80
+
81
+ ```html
82
+ <link rel="stylesheet" href="/assets/application-abc123.css"
83
+ integrity="sha384-xyz789...">
84
+ <script src="/assets/application-def456.js"
85
+ integrity="sha384-uvw012..."></script>
86
+ ```
87
+
88
+ **Important**: SRI only works in secure contexts (HTTPS) or during local development. The integrity hashes are automatically omitted when serving over HTTP in production for security reasons.
89
+
90
+ ### Bulk stylesheet inclusion with SRI
91
+
92
+ Propshaft extends `stylesheet_link_tag` with special symbols for bulk inclusion:
93
+
94
+ ```erb
95
+ <%= stylesheet_link_tag :all, integrity: true %> <!-- All stylesheets -->
96
+ <%= stylesheet_link_tag :app, integrity: true %> <!-- Only app/assets stylesheets -->
97
+ ```
98
+
99
+ ## Improving performance in development
100
+
101
+ Before every request Propshaft checks if any asset was updated to decide if a cache sweep is needed. This verification is done using the application's configured file watcher which, by default, is `ActiveSupport::FileUpdateChecker`.
102
+
103
+ If you have a lot of assets in your project, you can improve performance by adding the `listen` gem to the development group in your Gemfile, and this line to the `development.rb` environment file:
104
+
105
+ ```ruby
106
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
107
+ ```
108
+
109
+
110
+ ## Migrating from Sprockets
111
+
112
+ Propshaft does a lot less than Sprockets, by design, so it might well be a fair bit of work to migrate if it's even desirable. This is particularly true if you rely on Sprockets to provide any form of transpiling, like CoffeeScript or Sass, or if you rely on any gems that do. You'll need to either stop transpiling or use a Node-based transpiler, like those in [`jsbundling-rails`](https://github.com/rails/jsbundling-rails) and [`cssbundling-rails`](https://github.com/rails/cssbundling-rails).
113
+
114
+ On the other hand, if you're already bundling JavaScript and CSS through a Node-based setup, then Propshaft is going to slot in easily. Since you don't need another tool to bundle or transpile. Just to digest and serve.
115
+
116
+ But for greenfield apps using the default import-map approach, Propshaft can also work well, if you're able to deal with vanilla CSS.
117
+
118
+
119
+ ## License
120
+
121
+ Propshaft is released under the [MIT License](https://opensource.org/licenses/MIT).