我创建了一个引擎,它提供了一个ui组件作为单元格.相应的gem(criteria_operator-ui_component)在lib文件夹中几乎不包含任何代码,因为要使单元格正常运行,我必须在资源路径中工作.gem的基本文件如下所示:
require 'criteria_operator/ui_component/engine'
require 'cells/rails'
module CriteriaOperator
  module UiComponent
    # Your code goes here...
  end
end
引擎不包含太多:
module CriteriaOperator
  module UiComponent
    class Engine < ::Rails::Engine
      require 'jquery-rails'
      require 'criteria_operator'
      isolate_namespace CriteriaOperator::UiComponent
    end
  end
end
对我来说,看起来宝石甚至不知道细胞,但据我所知,我不允许在lib文件夹之外包含任何东西.此外,在项目中测试虚拟应用程序中的单元格工作正常.
现在我在一个真正的Rails应用程序中使用这个引擎.在gemfile中,我包括以下内容:
gem 'criteria_operator' 
gem 'cells'       # i added these three, because `bundler list` didn't show me
gem 'cells-rails' # `cells-rails` and `cells-erb` even though they are listed
gem 'cells-erb'   # as dependencies for the engine
gem 'criteria_operator-ui_component'
我登上了路线
mount CriteriaOperator::UiComponent::Engine => …我在我的ruby-on-rails项目中使用cancan和cellsgems.
如何can?从单元格内访问方法?
谢谢.
我已经阅读了几个关于rails的单元格的示例,但没有找到一些示例来说明如何从单元格创建一个完全隔离的小部件.
通过隔离,我的意思是一个小部件,它有自己的css/javascript/...并且只需要在rails文件夹中复制.
这对细胞来说是否可行?
我正在使用Kaminari :: Cells gem,当我在单元格视图中使用paginate方法时,什么都没有显示出来.我检查了,paginate方法只是返回"\n".
ruby-on-rails kaminari rails-cells trailblazer rails-cells-4