Uncaught TypeError: Невозможно прочесть схему свойства undefined в stimulus_reflex.js: 328 в utils.js: 50

У меня был повторный стимул-рефлекс для публикации и отмены публикации, но кнопка не работает, дайте мне эту ошибку в консоли, я не знаю, где я ошибся

стимул_reflex.js

      var StimulusReflexController = /*#__PURE__*/function (_Controller) {
  _inherits(StimulusReflexController, _Controller);

  var _super = _createSuper(StimulusReflexController);

  function StimulusReflexController() {
    var _this;

    _classCallCheck(this, StimulusReflexController);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));
    register(_assertThisInitialized(_this));
    return _this;
  }

  return StimulusReflexController;
}(Controller); // Sets up declarative reflex behavior.
// Any elements that define data-reflex will automatically be wired up with the default StimulusReflexController.
//

и это utils.js

      export var debounce = function debounce(callback) {
  var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 250;
  var timeoutId;
  return function () {
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    clearTimeout(timeoutId);
    timeoutId = setTimeout(function () {
      timeoutId = null;
      callback.apply(void 0, args);
    }, delay);
  };
};

это мой publisher_reflex.rb

      class PublisherReflex < ApplicationReflex
  def toggle
    post = Post.find(element.dataset[:post_id])
    post.published? ? post.update(published: false, published_at: nil) : post.update(published: true, published_at: Time.now)
  end
end

это edit.html.rb

       <div class="card-footer">
        <% if @post.published? %>
        <a href="#"
        class='btn btn-warning col-12'
        data-reflex ='click->PublisherReflex#unpublish'
        data-post-id = '<%= @post.id %>'
        >
        Unpublish
      </a>
        <% else %>
        <a href="#" class="btn btn-dark col-12"
        data-reflex='click->PublisherReflex#publish'
        data-post-id = '<%= @post.id %>'
        >
        Publish
      </a>
        <%end%>
      </div>

1 ответ

У вас есть сервер Redis, работающий в фоновом режиме? Это решение моей проблемы.

brew updatebrew install redisbrew services start redis

Другие вопросы по тегам