How to make recurring_select gem work with Rails 6 and Webpacker

Viewed 297

recurring_select is a gem that makes recurring events easy to select in a popup form. Demo here: http://recurring-select-demo.herokuapp.com/

(gitgub: https://github.com/GetJobber/recurring_select, see also GoRails cast on using it https://gorails.com/episodes/recurring-events)

The problem I've experienced is in including the js.coffee, and js.coffee.erb assets into my app

Following the instructions to require assets doesn't work e.g. in application.js: //= require recurring_select

I had limited success by making a change so that coffeescript files could be included and I copied the file in directly. This makes the popup appear (as seen in the image below), but it is missing but the remaining js.coffee.erb which provides the dialog (red box in image)

Screenshot from demo of working popup and dialog in red box which isn't been loaded (js.coffee.erb file)

Any recommendations and workaround suggestions would be greatly appreciated


My files as per the gem instructions:

Application.js

...
require("trix")
require("@rails/actiontext")
require('./calendar/create_booking.js')

//= require recurring_select
//= require jquery-mobile-rs
...

Application.scss

...
@import 'tippy.js/dist/tippy.css';
@import 'flatpickr/dist/flatpickr.css';

//= require recurring_select
//= require jquery-mobile-rs
...
1 Answers

Extract the relevant assets, per this comment: https://github.com/GetJobber/recurring_select/issues/125#issuecomment-557345359

Import the files: https://github.com/GetJobber/recurring_select/issues/125#issuecomment-596663751

You will experience a few broken parts, that are to be decided by yourself what you do with those:

  • 2 missing files (throbber and cancel)
  • Rails.application.config.action_controller.relative_url_root

Possible solution: Comment out the 2 missing files and remove the <%= Rails.application.config.action_controller.relative_url_root %> completely, and it will work.

Related