Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken kaminari pagination after upgrade to cells 4 #381

Open
Loremaster opened this issue Feb 25, 2016 · 8 comments
Open

Broken kaminari pagination after upgrade to cells 4 #381

Loremaster opened this issue Feb 25, 2016 · 8 comments

Comments

@Loremaster
Copy link

I started to upgrade cells from 3.11.2 to 4.0.4 basing on https://github.com/apotonick/cells/wiki/From-Cells-3-to-Cells-4---Upgrading-Guide (I also added cells-slim gem since my views are in slim). So I have such cell now:

app/cells/permissions_cell.rb

class PermissionsCell < Cell::ViewModel
  include LayoutHelper

  # Simple form.
  include ActionView::RecordIdentifier
  include ActionView::Helpers::FormHelper
  include SimpleForm::ActionViewExtensions::FormHelper

  def display resource, users, invitation = nil
    @resource = resource
    @invitation = invitation || Invitation.new
    @users = users
    render
  end

  def form resource, invitation
    @invitation = invitation
    @resource = resource
    render
  end

  def list resource, users
    @resource = resource
    @users = users
    render
  end

  def user user, resource
    @user = user
    @resource = resource
    @permission = @user.permission_for(@resource)
    render
  end
end

And I have cell view:

app/cells/views/permissions/list.slim

- if @users.any?
  table id="permissions_table" class="table table-striped"
    thead
      tr
        th Name
        th Email
        th Role
        th Enabled SMTP
        th width=300 class="actions" Actions
    tbody
      - @users.each do |user|
        = cell(:permissions).call(:user, user, @resource)

  = paginate @users

I also had such fix:

config/initializers/kaminari_config.rb

# Fix for cells gem and kaminari.
Kaminari::Helpers::Tag.class_eval do
  def to_s(locals = {}) #:nodoc:
    @template.render :partial => "../views/kaminari/#{@theme}#{self.class.name.demodulize.underscore}", :locals => @options.merge(locals)
  end
end

But after upgrade = paginate @users causes NoMethodError - undefined method 'paginate' for #PermissionsCell:0x007ffe8d604b20 error when I try to open my page with users (as I mentioned earlier I didn't have such error before the upgrade). Here is my error trace:

NoMethodError - undefined method `paginate' for #<PermissionsCell:0x007ffe8d604b20>:
   () cells/permissions/list.slim:15:in `block in singleton class'
   () cells/permissions/list.slim:65535:in `singleton class'
   () cells/permissions/list.slim:65533:in `__tilt_70365611426260'
  tilt (1.4.1) lib/tilt/template.rb:170:in `evaluate'
  tilt (1.4.1) lib/tilt/template.rb:103:in `render'
  cells (4.0.4) lib/cell/view_model.rb:133:in `render_template'
  cells-slim (0.0.4) lib/cell/slim.rb:8:in `render_template'
  cells (4.0.4) lib/cell/view_model.rb:114:in `render_to_string'
  cells (4.0.4) lib/cell/view_model.rb:107:in `render'
   () Users/serj/Projects/Email_platform/app/cells/permissions_cell.rb:26:in `list'
  cells (4.0.4) lib/cell/view_model.rb:121:in `render_state'
  cells (4.0.4) lib/cell/caching.rb:47:in `render_state'
  cells (4.0.4) lib/cell/view_model.rb:98:in `call'
  cells (4.0.4) lib/cell/rails.rb:47:in `call'
   () cells/permissions/display.slim:4:in `block in singleton class'
   () cells/permissions/display.slim:65535:in `singleton class'
   () cells/permissions/display.slim:65533:in `__tilt_70365611426260'
  tilt (1.4.1) lib/tilt/template.rb:170:in `evaluate'
  tilt (1.4.1) lib/tilt/template.rb:103:in `render'
  cells (4.0.4) lib/cell/view_model.rb:133:in `render_template'
  cells-slim (0.0.4) lib/cell/slim.rb:8:in `render_template'
  cells (4.0.4) lib/cell/view_model.rb:114:in `render_to_string'
  cells (4.0.4) lib/cell/view_model.rb:107:in `render'
   () Users/serj/Projects/Email_platform/app/cells/permissions_cell.rb:14:in `display'
  cells (4.0.4) lib/cell/view_model.rb:121:in `render_state'
  cells (4.0.4) lib/cell/caching.rb:47:in `render_state'
  cells (4.0.4) lib/cell/view_model.rb:98:in `call'
  cells (4.0.4) lib/cell/rails.rb:47:in `call'
   () Users/serj/Projects/Email_platform/app/views/resource_users/_index.html.slim:1:in `_app_views_resource_users__index_html_slim__3998177108781659619_70365613922460'
  actionview (4.1.14) lib/action_view/template.rb:145:in `block in render'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `instrument'
  actionview (4.1.14) lib/action_view/template.rb:339:in `instrument'
  actionview (4.1.14) lib/action_view/template.rb:143:in `render'
  rack-mini-profiler (0.9.7) lib/mini_profiler/profiling_methods.rb:106:in `block in profile_method'
  actionview (4.1.14) lib/action_view/renderer/partial_renderer.rb:306:in `render_partial'
  actionview (4.1.14) lib/action_view/renderer/partial_renderer.rb:279:in `block in render'
  actionview (4.1.14) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `instrument'
  actionview (4.1.14) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionview (4.1.14) lib/action_view/renderer/partial_renderer.rb:278:in `render'
  actionview (4.1.14) lib/action_view/renderer/renderer.rb:47:in `render_partial'
  actionview (4.1.14) lib/action_view/helpers/rendering_helper.rb:35:in `render'
  haml (4.0.5) lib/haml/helpers/action_view_mods.rb:12:in `render_with_haml'
   () Users/serj/Projects/Email_platform/app/views/resource_users/index.html.slim:11:in `_app_views_resource_users_index_html_slim__1110490679345300506_70365634324680'
  actionview (4.1.14) lib/action_view/template.rb:145:in `block in render'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `instrument'
  actionview (4.1.14) lib/action_view/template.rb:339:in `instrument'
  actionview (4.1.14) lib/action_view/template.rb:143:in `render'
  rack-mini-profiler (0.9.7) lib/mini_profiler/profiling_methods.rb:106:in `block in profile_method'
  actionview (4.1.14) lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
  actionview (4.1.14) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `instrument'
  actionview (4.1.14) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionview (4.1.14) lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
  actionview (4.1.14) lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
  actionview (4.1.14) lib/action_view/renderer/template_renderer.rb:53:in `render_template'
  actionview (4.1.14) lib/action_view/renderer/template_renderer.rb:17:in `render'
  actionview (4.1.14) lib/action_view/renderer/renderer.rb:42:in `render_template'
  actionview (4.1.14) lib/action_view/renderer/renderer.rb:23:in `render'
  actionview (4.1.14) lib/action_view/rendering.rb:99:in `_render_template'
  actionpack (4.1.14) lib/action_controller/metal/streaming.rb:217:in `_render_template'
  actionview (4.1.14) lib/action_view/rendering.rb:82:in `render_to_body'
  actionpack (4.1.14) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
  actionpack (4.1.14) lib/action_controller/metal/renderers.rb:32:in `render_to_body'
  actionpack (4.1.14) lib/abstract_controller/rendering.rb:25:in `render'
  actionpack (4.1.14) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
  activesupport (4.1.14) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
   () Users/serj/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
  activesupport (4.1.14) lib/active_support/core_ext/benchmark.rb:12:in `ms'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
  activerecord (4.1.14) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:43:in `render'
  remotipart (1.2.1) lib/remotipart/render_overrides.rb:14:in `render_with_remotipart'
  actionpack (4.1.14) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
  actionpack (4.1.14) lib/action_controller/metal/responder.rb:238:in `default_render'
  actionpack (4.1.14) lib/action_controller/metal/responder.rb:165:in `to_html'
  responders (1.1.1) lib/responders/flash_responder.rb:107:in `to_html'
  actionpack (4.1.14) lib/action_controller/metal/responder.rb:158:in `respond'
  actionpack (4.1.14) lib/action_controller/metal/responder.rb:151:in `call'
  actionpack (4.1.14) lib/action_controller/metal/mime_responds.rb:400:in `respond_with'
   () Users/serj/Projects/Email_platform/app/controllers/resource_users_controller.rb:11:in `index'
  actionpack (4.1.14) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.1.14) lib/abstract_controller/base.rb:189:in `process_action'
  actionpack (4.1.14) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.1.14) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.1.14) lib/active_support/callbacks.rb:113:in `call'
  activesupport (4.1.14) lib/active_support/callbacks.rb:552:in `block (2 levels) in compile'
  activesupport (4.1.14) lib/active_support/callbacks.rb:502:in `call'
  activesupport (4.1.14) lib/active_support/callbacks.rb:86:in `run_callbacks'
  actionpack (4.1.14) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.1.14) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `instrument'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.1.14) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.1.14) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.1.14) lib/abstract_controller/base.rb:136:in `process'
  actionview (4.1.14) lib/action_view/rendering.rb:30:in `process'
  rack-mini-profiler (0.9.7) lib/mini_profiler/profiling_methods.rb:106:in `block in profile_method'
  actionpack (4.1.14) lib/action_controller/metal.rb:196:in `dispatch'
  actionpack (4.1.14) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.1.14) lib/action_controller/metal.rb:232:in `block in action'
  actionpack (4.1.14) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
  actionpack (4.1.14) lib/action_dispatch/routing/route_set.rb:50:in `call'
  actionpack (4.1.14) lib/action_dispatch/journey/router.rb:73:in `block in call'
  actionpack (4.1.14) lib/action_dispatch/journey/router.rb:59:in `call'
  actionpack (4.1.14) lib/action_dispatch/routing/route_set.rb:692:in `call'

I tried couple things to fix that but I didn't have any lack

My attempt to fix via kaminari-cells gem

I tried to fix the problem by adding gem kaminari-cells to my Gemfile. After that I removed this:

config/initializers/kaminari_config.rb

# Fix for cells gem and kaminari.
Kaminari::Helpers::Tag.class_eval do
  def to_s(locals = {}) #:nodoc:
    @template.render :partial => "../views/kaminari/#{@theme}#{self.class.name.demodulize.underscore}", :locals => @options.merge(locals)
  end
end

And also I added to my cell that line:

app/cells/permissions_cell.rb

class PermissionsCell < Cell::ViewModel
  include Kaminari::Cells
  # ...
end

but that caused another weird error - NameError - uninitialized constant Cell::Rails:

NameError - uninitialized constant Cell::Rails:
  activesupport (4.1.14) lib/active_support/dependencies.rb:519:in `load_missing_constant'
  activesupport (4.1.14) lib/active_support/dependencies.rb:180:in `const_missing'
  kaminari-cells (0.0.3) lib/kaminari/cells.rb:7:in `block in <module:Cells>'
  activesupport (4.1.14) lib/active_support/concern.rb:120:in `append_features'
   () Users/serj/Projects/Email_platform/app/cells/permissions_cell.rb:2:in `<class:PermissionsCell>'
   () Users/serj/Projects/Email_platform/app/cells/permissions_cell.rb:1:in `<top (required)>'
  activesupport (4.1.14) lib/active_support/dependencies.rb:443:in `block in load_file'
  activesupport (4.1.14) lib/active_support/dependencies.rb:633:in `new_constants_in'
  activesupport (4.1.14) lib/active_support/dependencies.rb:442:in `load_file'
  activesupport (4.1.14) lib/active_support/dependencies.rb:342:in `require_or_load'
  activesupport (4.1.14) lib/active_support/dependencies.rb:480:in `load_missing_constant'
  activesupport (4.1.14) lib/active_support/dependencies.rb:180:in `const_missing'
  activesupport (4.1.14) lib/active_support/inflector/methods.rb:238:in `block in constantize'
  activesupport (4.1.14) lib/active_support/inflector/methods.rb:236:in `constantize'
  activesupport (4.1.14) lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
  cells (4.0.4) lib/cell/view_model.rb:74:in `class_from_cell_name'
  cells (4.0.4) lib/cell/view_model.rb:36:in `cell'
  cells (4.0.4) lib/cell/rails.rb:6:in `cell'
  cells (4.0.4) lib/cell/rails.rb:20:in `cell'
   () Users/serj/Projects/Email_platform/app/views/resource_users/_index.html.slim:1:in `_app_views_resource_users__index_html_slim__4037785881118439438_70317071663680'
  actionview (4.1.14) lib/action_view/template.rb:145:in `block in render'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `instrument'
  actionview (4.1.14) lib/action_view/template.rb:339:in `instrument'
  actionview (4.1.14) lib/action_view/template.rb:143:in `render'
  rack-mini-profiler (0.9.7) lib/mini_profiler/profiling_methods.rb:106:in `block in profile_method'
  actionview (4.1.14) lib/action_view/renderer/partial_renderer.rb:306:in `render_partial'
  actionview (4.1.14) lib/action_view/renderer/partial_renderer.rb:279:in `block in render'
  actionview (4.1.14) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `instrument'
  actionview (4.1.14) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionview (4.1.14) lib/action_view/renderer/partial_renderer.rb:278:in `render'
  actionview (4.1.14) lib/action_view/renderer/renderer.rb:47:in `render_partial'
  actionview (4.1.14) lib/action_view/helpers/rendering_helper.rb:35:in `render'
  haml (4.0.5) lib/haml/helpers/action_view_mods.rb:12:in `render_with_haml'
   () Users/serj/Projects/Email_platform/app/views/resource_users/index.html.slim:11:in `_app_views_resource_users_index_html_slim__4125873031575201276_70317046501220'
  actionview (4.1.14) lib/action_view/template.rb:145:in `block in render'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `instrument'
  actionview (4.1.14) lib/action_view/template.rb:339:in `instrument'
  actionview (4.1.14) lib/action_view/template.rb:143:in `render'
  rack-mini-profiler (0.9.7) lib/mini_profiler/profiling_methods.rb:106:in `block in profile_method'
  actionview (4.1.14) lib/action_view/renderer/template_renderer.rb:55:in `block (2 levels) in render_template'
  actionview (4.1.14) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `instrument'
  actionview (4.1.14) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
  actionview (4.1.14) lib/action_view/renderer/template_renderer.rb:54:in `block in render_template'
  actionview (4.1.14) lib/action_view/renderer/template_renderer.rb:62:in `render_with_layout'
  actionview (4.1.14) lib/action_view/renderer/template_renderer.rb:53:in `render_template'
  actionview (4.1.14) lib/action_view/renderer/template_renderer.rb:17:in `render'
  actionview (4.1.14) lib/action_view/renderer/renderer.rb:42:in `render_template'
  actionview (4.1.14) lib/action_view/renderer/renderer.rb:23:in `render'
  actionview (4.1.14) lib/action_view/rendering.rb:99:in `_render_template'
  actionpack (4.1.14) lib/action_controller/metal/streaming.rb:217:in `_render_template'
  actionview (4.1.14) lib/action_view/rendering.rb:82:in `render_to_body'
  actionpack (4.1.14) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
  actionpack (4.1.14) lib/action_controller/metal/renderers.rb:32:in `render_to_body'
  actionpack (4.1.14) lib/abstract_controller/rendering.rb:25:in `render'
  actionpack (4.1.14) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
  activesupport (4.1.14) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
   () Users/serj/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
  activesupport (4.1.14) lib/active_support/core_ext/benchmark.rb:12:in `ms'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
  activerecord (4.1.14) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:43:in `render'
  remotipart (1.2.1) lib/remotipart/render_overrides.rb:14:in `render_with_remotipart'
  actionpack (4.1.14) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
  actionpack (4.1.14) lib/action_controller/metal/responder.rb:238:in `default_render'
  actionpack (4.1.14) lib/action_controller/metal/responder.rb:165:in `to_html'
  responders (1.1.1) lib/responders/flash_responder.rb:107:in `to_html'
  actionpack (4.1.14) lib/action_controller/metal/responder.rb:158:in `respond'
  actionpack (4.1.14) lib/action_controller/metal/responder.rb:151:in `call'
  actionpack (4.1.14) lib/action_controller/metal/mime_responds.rb:400:in `respond_with'
   () Users/serj/Projects/Email_platform/app/controllers/resource_users_controller.rb:11:in `index'
  actionpack (4.1.14) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.1.14) lib/abstract_controller/base.rb:189:in `process_action'
  actionpack (4.1.14) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.1.14) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.1.14) lib/active_support/callbacks.rb:113:in `call'
  activesupport (4.1.14) lib/active_support/callbacks.rb:552:in `block (2 levels) in compile'
  activesupport (4.1.14) lib/active_support/callbacks.rb:502:in `call'
  activesupport (4.1.14) lib/active_support/callbacks.rb:86:in `run_callbacks'
  actionpack (4.1.14) lib/abstract_controller/callbacks.rb:19:in `process_action'
  actionpack (4.1.14) lib/action_controller/metal/rescue.rb:29:in `process_action'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `block in instrument'
  activesupport (4.1.14) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
  activesupport (4.1.14) lib/active_support/notifications.rb:159:in `instrument'
  actionpack (4.1.14) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
  actionpack (4.1.14) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
  activerecord (4.1.14) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
  actionpack (4.1.14) lib/abstract_controller/base.rb:136:in `process'
  actionview (4.1.14) lib/action_view/rendering.rb:30:in `process'
  rack-mini-profiler (0.9.7) lib/mini_profiler/profiling_methods.rb:106:in `block in profile_method'
  actionpack (4.1.14) lib/action_controller/metal.rb:196:in `dispatch'
  actionpack (4.1.14) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
  actionpack (4.1.14) lib/action_controller/metal.rb:232:in `block in action'
  actionpack (4.1.14) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
  actionpack (4.1.14) lib/action_dispatch/routing/route_set.rb:50:in `call'
  actionpack (4.1.14) lib/action_dispatch/journey/router.rb:73:in `block in call'
  actionpack (4.1.14) lib/action_dispatch/journey/router.rb:59:in `call'
  actionpack (4.1.14) lib/action_dispatch/routing/route_set.rb:692:in `call'

My attempt to fix my using code from kaminari-cells gem

I also tried to copy and use code from kaminari-cells:

app/cells/permissions_cell.rb

class PermissionsCell < Cell::ViewModel
  include LayoutHelper

  # Simple form.
  include ActionView::RecordIdentifier
  include ActionView::Helpers::FormHelper
  include SimpleForm::ActionViewExtensions::FormHelper

  # Kaminari
  include Kaminari::ActionViewExtension
  include ActionView::Helpers::OutputSafetyHelper
  include ActionView::Helpers::TranslationHelper

  def paginate(scope, options = {}, &block)
    options = options.reverse_merge(:views_prefix => "../views/")
    super
  end
end

which caused another error - Cell::TemplateMissingError - Template missing: view:to_s.slimprefixes: ["app/cells/permissions"]

Cell::TemplateMissingError - Template missing: view: `to_s.slim` prefixes: ["app/cells/permissions"]:
  cells (4.0.4) lib/cell/view_model.rb:182:in `find_template'
  cells (4.0.4) lib/cell/view_model.rb:112:in `render_to_string'
  cells (4.0.4) lib/cell/view_model.rb:107:in `render'
  kaminari (0.16.3) lib/kaminari/helpers/tags.rb:25:in `to_s'
  kaminari (0.16.3) lib/kaminari/helpers/paginator.rb:100:in `to_s'
  kaminari (0.16.3) lib/kaminari/helpers/action_view_extension.rb:21:in `paginate'
   () Users/serj/Projects/Email_platform/app/cells/permissions_cell.rb:43:in `paginate'
   () cells/permissions/list.slim:15:in `block in singleton class'
   () cells/permissions/list.slim:65535:in `singleton class'
   () cells/permissions/list.slim:65533:in `__tilt_70178251866580'
  tilt (1.4.1) lib/tilt/template.rb:170:in `evaluate'
  tilt (1.4.1) lib/tilt/template.rb:103:in `render'
  cells (4.0.4) lib/cell/view_model.rb:133:in `render_template'
  cells-slim (0.0.4) lib/cell/slim.rb:8:in `render_template'
  cells (4.0.4) lib/cell/view_model.rb:114:in `render_to_string'
  cells (4.0.4) lib/cell/view_model.rb:107:in `render'
   () Users/serj/Projects/Email_platform/app/cells/permissions_cell.rb:31:in `list'
  cells (4.0.4) lib/cell/view_model.rb:121:in `render_state'
  cells (4.0.4) lib/cell/caching.rb:47:in `render_state'
  cells (4.0.4) lib/cell/view_model.rb:98:in `call'
  cells (4.0.4) lib/cell/rails.rb:47:in `call'
   () cells/permissions/display.slim:4:in `block in singleton class'
   () cells/permissions/display.slim:65535:in `singleton class'
   () cells/permissions/display.slim:65533:in `__tilt_70178251866580'
  tilt (1.4.1) lib/tilt/template.rb:170:in `evaluate'
  tilt (1.4.1) lib/tilt/template.rb:103:in `render'
  cells (4.0.4) lib/cell/view_model.rb:133:in `render_template'
  cells-slim (0.0.4) lib/cell/slim.rb:8:in `render_template'
  cells (4.0.4) lib/cell/view_model.rb:114:in `render_to_string'
  cells (4.0.4) lib/cell/view_model.rb:107:in `render'
   () Users/serj/Projects/Email_platform/app/cells/permissions_cell.rb:19:in `display'
  cells (4.0.4) lib/cell/view_model.rb:121:in `render_state'
  cells (4.0.4) lib/cell/caching.rb:47:in `render_state'
  cells (4.0.4) lib/cell/view_model.rb:98:in `call'
  cells (4.0.4) lib/cell/rails.rb:47:in `call'
   () Users/serj/Projects/Email_platform/app/views/resource_users/_index.html.slim:1:in `_app_views_resource_users__index_html_slim__4442206953687667164_70178361081960'

Please can somebody help with fixing that?

@apotonick
Copy link
Member

Please update kaminari-cells to 0.0.4.

@everaldo
Copy link

@apotonick , I'm using Rails 5.1 , kaminari-cells (last version), cells (last version) and getting a similar error

/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:84:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'kaminari-cells'. (Bundler::GemRequireError)
Gem Load Error is: uninitialized constant Kaminari::ActionViewExtension
Backtrace for gem load error is:
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/kaminari-cells-0.0.4/lib/kaminari-cells.rb:9:in `<module:CellsHelper>'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/kaminari-cells-0.0.4/lib/kaminari-cells.rb:8:in `<module:Helpers>'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/kaminari-cells-0.0.4/lib/kaminari-cells.rb:7:in `<module:Kaminari>'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/kaminari-cells-0.0.4/lib/kaminari-cells.rb:6:in `<top (required)>'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:81:in `require'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:76:in `each'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:76:in `block in require'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:65:in `each'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:65:in `require'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler.rb:114:in `require'
/home/everaldo/Code/cherie/v1/config/application.rb:7:in `<top (required)>'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:133:in `require'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:133:in `block in perform'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `tap'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `perform'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/command/base.rb:63:in `perform'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/command.rb:44:in `invoke'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>'
/home/everaldo/Code/cherie/v1/bin/rails:9:in `require'
/home/everaldo/Code/cherie/v1/bin/rails:9:in `<top (required)>'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/home/everaldo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
/home/everaldo/Code/cherie/v1/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
Bundler Error Backtrace:
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:80:in `block (2 levels) in require'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:76:in `each'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:76:in `block in require'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:65:in `each'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler/runtime.rb:65:in `require'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/lib/bundler.rb:114:in `require'
        from /home/everaldo/Code/cherie/v1/config/application.rb:7:in `<top (required)>'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:133:in `require'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:133:in `block in perform'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `tap'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/commands/server/server_command.rb:130:in `perform'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/command/base.rb:63:in `perform'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/command.rb:44:in `invoke'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.1.6/lib/rails/commands.rb:16:in `<top (required)>'
        from /home/everaldo/Code/cherie/v1/bin/rails:9:in `require'
        from /home/everaldo/Code/cherie/v1/bin/rails:9:in `<top (required)>'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
        from /home/everaldo/.rbenv/versions/2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:68:in `require'
        from /home/everaldo/Code/cherie/v1/bin/spring:15:in `<top (required)>'
        from bin/rails:3:in `load'
        from bin/rails:3:in `<main>'

@niek95
Copy link

niek95 commented Aug 29, 2018

Have the same errors here, can't seem to get pagination working in cells anymore

@everaldo
Copy link

@niek95 , I've solved by forking kaminari-cells and updating kaminari version.

You can check it here:

everaldo/kaminari-cells@0930b8f

@niek95
Copy link

niek95 commented Aug 30, 2018

Do you copy the kaminari views and change the config as well? I still get an error that it can't find the template view: _paginator.html.haml, even though it is finding the correct version of kaminari-cells

@niek95
Copy link

niek95 commented Aug 30, 2018

Nevermind, it was a problem with Haml, solved by generating the views. Thanks for your help!

@everaldo
Copy link

@niek95 , probably it's this error: https://stackoverflow.com/questions/35188101/kaminaricells-paginate-method-not-rendering-anything#35188102

Sorry, I'd forgot to mention that.

@niek95
Copy link

niek95 commented Sep 3, 2018

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants