Issue Passing parameters from erb template to controller in Rails - ruby-on-rails

I am trying to call a method in view template from its respective controller which is acting weirdly based on different conditions.
PLease note I have tried this after getting failure on this
Triply nested model's form in rails showing error
First of all the controller method is defined as ->
helper_method :find_feature
def find_feature(fid)
#project.features.find(fid)
end
And the view file code where this method is called ->
<% #project.features.each do |fet| %>
<%= "#{fet.name} #{fet.id} " %> #It does work!!
<%= render partial: "taskform",locals: { fetr: find_feature(fet.id) } %>
<% end %>
This throws error as Couldn't find Feature without an ID
in the screenshot islt is shown params[:id] is used that is not right sorry for that I have used the method which is written above as find_feature(fid) very sorry I will update the screenshot once I get to my mqchine
**
the error shows Couldn't find a feature without an id when called by find_feature(fet.id)
**
BUt when I explicitly test with an id, manually, like->
<%= render partial: "taskform", locals: { fetr: find_feature(7) } %>
This works !
Full stack trace-
activerecord (5.2.3) lib/active_record/relation/finder_methods.rb:433:in `find_with_ids'
activerecord (5.2.3) lib/active_record/relation/finder_methods.rb:69:in `find'
activerecord (5.2.3) lib/active_record/associations/collection_association.rb:100:in `find'
activerecord (5.2.3) lib/active_record/associations/collection_proxy.rb:140:in `find'
app/controllers/projects_controller.rb:7:in `find_feature'
actionpack (5.2.3) lib/abstract_controller/helpers.rb:67:in `find_feature'
app/views/projects/show.html.erb:66:in `block in _app_views_projects_show_html_erb__3383934460746758134_70317115637280'
activerecord (5.2.3) lib/active_record/relation/delegation.rb:71:in `each'
activerecord (5.2.3) lib/active_record/relation/delegation.rb:71:in `each'
app/views/projects/show.html.erb:56:in `_app_views_projects_show_html_erb__3383934460746758134_70317115637280'
actionview (5.2.3) lib/action_view/template.rb:159:in `block in render'
activesupport (5.2.3) lib/active_support/notifications.rb:170:in `instrument'
actionview (5.2.3) lib/action_view/template.rb:354:in `instrument_render_template'
actionview (5.2.3) lib/action_view/template.rb:157:in `render'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:16:in `render'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:44:in `render_template'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:25:in `render'
actionview (5.2.3) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.2.3) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionview (5.2.3) lib/action_view/rendering.rb:84:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (5.2.3) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/home/ayan/.rvm/rubies/ruby-2.6.3/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:31:in `cleanup_view_runtime'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:45:in `render'
actionpack (5.2.3) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:194:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (5.2.3) lib/active_support/callbacks.rb:132:in `run_callbacks'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.3) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.3) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.3) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:840:in `call'
omniauth (1.9.0) lib/omniauth/strategy.rb:192:in `call!'
omniauth (1.9.0) lib/omniauth/strategy.rb:169:in `call'
omniauth (1.9.0) lib/omniauth/builder.rb:64:in `call'
rack (2.0.7) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.7) lib/rack/etag.rb:25:in `call'
rack (2.0.7) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.7) lib/rack/head.rb:12:in `call'
actionpack (5.2.3) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.0.7) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.7) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.3) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.3) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:30:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
railties (5.2.3) lib/rails/engine.rb:524:in `call'
puma (3.12.1) lib/puma/configuration.rb:227:in `call'
puma (3.12.1) lib/puma/server.rb:660:in `handle_request'
puma (3.12.1) lib/puma/server.rb:474:in `process_client'
puma (3.12.1) lib/puma/server.rb:334:in `block in run'
puma (3.12.1) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
Request
Parameters:
{"id"=>"4"}
Can anyone suggests what is the reason of this behaviour ?

You are calling the find_feature with this code find_feature(fet.id), so you want to pass the id as a parameter.
Define the helper_method this way then:
def find_feature(fid)
#project.features.find(fid)
end
params[:fid] will look for a request parameter with the key fid in the request's params hash, you are passing a specific value to the method when you call it.
EDIT: Anyway, I'm not sure why are you doing that, you already have the feature object on the fet variable inside the loop, just do this:
<%= render partial: "taskform",locals: { fetr: fet } %>

error shows method calling with parmas[:fid], but you defined method as find_feature(fid) for finding feature , so there must be other method which is overriding , try it by giving different name like find_project_features it will work

Related

administrate gem customizing labels used for resources in dashboard collections

The administrate gem guide indicates the labels for ressources can be adapted to attributes of that model
def display_resource(user)
user.name
end
However this does not appear to function on relations
Card belongs_to User and the goal is to represent the ressource user in the CardDashboard with
card.user.last_name + ', ' + card.user.first_name
However, even a succinct definition
def display_resource(user)
card.user.last_name
end
leads to undefined local variable or method 'card' for #<CardDashboard
It appears the display_resource definition is only applicable to its own class as
def display_resource(user)
user.last_name + ', ' + user.first_name
end
will work.
Is there a mechanism by which the resource label can be defined on a per-class basis using nested attributes ?
update error stack
app/dashboards/user_dashboard.rb:212:in `display_resource'
app/views/admin/cards/_form.html.erb:38
app/views/admin/cards/_form.html.erb:36:in `each'
app/views/admin/cards/_form.html.erb:36
app/views/admin/cards/_form.html.erb:17
app/views/admin/cards/edit.html.erb:35
update
Full stack trace
administrate (0.14.0) lib/administrate/base_dashboard.rb:39:in `block in attribute_type_for'
administrate (0.14.0) lib/administrate/base_dashboard.rb:38:in `fetch'
administrate (0.14.0) lib/administrate/base_dashboard.rb:38:in `attribute_type_for'
administrate (0.14.0) lib/administrate/page/base.rb:30:in `attribute_field'
administrate (0.14.0) lib/administrate/page/form.rb:15:in `block in attributes'
administrate (0.14.0) lib/administrate/page/form.rb:14:in `map'
administrate (0.14.0) lib/administrate/page/form.rb:14:in `attributes'
app/views/admin/cards/_form.html.erb:36
actionview (6.0.3.4) lib/action_view/helpers/capture_helper.rb:45:in `block in capture'
actionview (6.0.3.4) lib/action_view/helpers/capture_helper.rb:209:in `with_output_buffer'
actionview (6.0.3.4) lib/action_view/helpers/capture_helper.rb:45:in `capture'
actionview (6.0.3.4) lib/action_view/helpers/form_helper.rb:452:in `form_for'
client_side_validations (17.2.0) lib/client_side_validations/action_view/form_helper.rb:11:in `form_for'
app/views/admin/cards/_form.html.erb:17
actionview (6.0.3.4) lib/action_view/base.rb:274:in `_run'
actionview (6.0.3.4) lib/action_view/template.rb:185:in `block in render'
activesupport (6.0.3.4) lib/active_support/notifications.rb:182:in `instrument'
actionview (6.0.3.4) lib/action_view/template.rb:385:in `instrument_render_template'
actionview (6.0.3.4) lib/action_view/template.rb:183:in `render'
actionview (6.0.3.4) lib/action_view/renderer/partial_renderer.rb:357:in `block in render_partial'
actionview (6.0.3.4) lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.4) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `instrument'
actionview (6.0.3.4) lib/action_view/renderer/abstract_renderer.rb:87:in `instrument'
actionview (6.0.3.4) lib/action_view/renderer/partial_renderer.rb:346:in `render_partial'
actionview (6.0.3.4) lib/action_view/renderer/partial_renderer.rb:317:in `render'
actionview (6.0.3.4) lib/action_view/renderer/renderer.rb:65:in `render_partial_to_object'
actionview (6.0.3.4) lib/action_view/renderer/renderer.rb:53:in `render_partial'
actionview (6.0.3.4) lib/action_view/helpers/rendering_helper.rb:38:in `render'
app/views/admin/cards/edit.html.erb:35
actionview (6.0.3.4) lib/action_view/base.rb:274:in `_run'
actionview (6.0.3.4) lib/action_view/template.rb:185:in `block in render'
activesupport (6.0.3.4) lib/active_support/notifications.rb:182:in `instrument'
actionview (6.0.3.4) lib/action_view/template.rb:385:in `instrument_render_template'
actionview (6.0.3.4) lib/action_view/template.rb:183:in `render'
actionview (6.0.3.4) lib/action_view/renderer/template_renderer.rb:58:in `block (2 levels) in render_template'
actionview (6.0.3.4) lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.4) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `instrument'
actionview (6.0.3.4) lib/action_view/renderer/abstract_renderer.rb:87:in `instrument'
actionview (6.0.3.4) lib/action_view/renderer/template_renderer.rb:57:in `block in render_template'
actionview (6.0.3.4) lib/action_view/renderer/template_renderer.rb:65:in `render_with_layout'
actionview (6.0.3.4) lib/action_view/renderer/template_renderer.rb:56:in `render_template'
actionview (6.0.3.4) lib/action_view/renderer/template_renderer.rb:13:in `render'
actionview (6.0.3.4) lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
actionview (6.0.3.4) lib/action_view/renderer/renderer.rb:29:in `render_to_object'
actionview (6.0.3.4) lib/action_view/rendering.rb:117:in `block in _render_template'
actionview (6.0.3.4) lib/action_view/base.rb:304:in `in_rendering_context'
actionview (6.0.3.4) lib/action_view/rendering.rb:116:in `_render_template'
actionpack (6.0.3.4) lib/action_controller/metal/streaming.rb:218:in `_render_template'
actionview (6.0.3.4) lib/action_view/rendering.rb:103:in `render_to_body'
actionpack (6.0.3.4) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (6.0.3.4) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (6.0.3.4) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (6.0.3.4) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (6.0.3.4) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/home/uelcom/.rbenv/versions/2.6.1/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
activesupport (6.0.3.4) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (6.0.3.4) lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:43:in `render'
administrate (0.14.0) app/controllers/administrate/application_controller.rb:38:in `edit'
actionpack (6.0.3.4) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.3.4) lib/abstract_controller/base.rb:195:in `process_action'
actionpack (6.0.3.4) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.3.4) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (6.0.3.4) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.3.4) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.4) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.4) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.3.4) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.3.4) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.3.4) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.3.4) lib/abstract_controller/base.rb:136:in `process'
actionview (6.0.3.4) lib/action_view/rendering.rb:39:in `process'
actionpack (6.0.3.4) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.0.3.4) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.3.4) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.3.4) lib/action_dispatch/routing/route_set.rb:834:in `call'
warden (1.2.9) lib/warden/manager.rb:36:in `block in call'
warden (1.2.9) lib/warden/manager.rb:34:in `catch'
warden (1.2.9) lib/warden/manager.rb:34:in `call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.3) lib/rack/etag.rb:27:in `call'
rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (6.0.3.4) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.3.4) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.3.4) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.3.4) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.1.0) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.1.0) lib/web_console/middleware.rb:19:in `block in call'
web-console (4.1.0) lib/web_console/middleware.rb:17:in `catch'
web-console (4.1.0) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.3.4) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.0.3.4) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.3.4) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.3.4) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
rails_same_site_cookie (0.1.8) lib/rails_same_site_cookie/middleware.rb:13:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.0.3.4) lib/action_dispatch/middleware/host_authorization.rb:82:in `call'
webpacker (4.3.0) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.3.4) lib/rails/engine.rb:527:in `call'
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:107:in `process_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:415:in `block (3 levels) in start_threads'
/usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
Update_Dashboards
require "administrate/base_dashboard"
class CardDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
user: Field::BelongsTo.with_options(
searchable: true,
searchable_fields: ['first_name', 'last_name', 'email', 'mobile']
),
id: Field::Number,
virtual: Field::Boolean,
blocked: Field::Boolean,
code: Field::String,
created_at: Field::DateTime,
updated_at: Field::DateTime,
}.freeze
COLLECTION_ATTRIBUTES = %i[
user
id
virtual
blocked
].freeze
SHOW_PAGE_ATTRIBUTES = %i[
user
id
virtual
blocked
code
created_at
updated_at
].freeze
FORM_ATTRIBUTES = %i[
user
virtual
blocked
code
].freeze
COLLECTION_FILTERS = {}.freeze
def display_resource(card)
card.user.last_name + ', ' + card.user.first_name
end
end
require "administrate/base_dashboard"
class UserDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
nation: Field::BelongsTo,
card: Field::HasOne,
notifications: Field::HasMany,
attachments: Field::HasMany,
id: Field::Number,
last_user_update: Field::Number,
last_user_update_at: Field::DateTime,
created_at: Field::DateTime,
updated_at: Field::DateTime,
}.freeze
COLLECTION_ATTRIBUTES = %i[
id
email
mobile
login_name
municipal
newsletter
].freeze
SHOW_PAGE_ATTRIBUTES = %i[
nation
card
notifications
attachments
id
email
first_name
last_name
date_of_birth
address
storage_bin
created_at
updated_at
].freeze
FORM_ATTRIBUTES = %i[
nation
card
notifications
attachments
email
mobile
].freeze
COLLECTION_FILTERS = {}.freeze
def display_resource(user)
user ? user.last_name + ', ' + user.first_name : "No user selected"
end
end
You say that you want to represent cards in the CardDashboard as follows:
card.user.last_name + ', ' + card.user.first_name
Then you use this code example, which is not working:
def display_resource(user)
card.user.last_name
end
I'm probably missing some info, and your example might have a typo, but what I would expect you to have is the following instead:
def display_resource(card)
card.user.last_name
end
The method CardDashboard#display_resource will receive cards as arguments, not users. You can't refer to card in your example because it's not defined (your argument is user instead). My example however should work, although it will represent the card as first_name+last_name everywhere, not just when represented as associations in other dashboards.

Rails ActiveStorage variant IntegrityError for some variants but unmodified images always show

My production database uses S3 and ActiveRecord to store images.
Since some time (could be related to the rails 6 upgrade but im not sure) a lot of the older images don't show their variants. Some newer ones however do. So it's not a general issue.
What puzzles me though, is that the non-variant image does show always
<p>
Variant, does not show
</p>
<%= image_tag #asset.image.variant(resize_to_fit: [200,200]) %>
<hr>
<p>
Original, shows
</p>
<%= image_tag #asset.image %>
<hr>
The log shows:
ActiveStorage::Blob Load (0.6ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = $1 LIMIT $2 [["id", 23], ["LIMIT", 1]]
S3 Storage (46.9ms) Checked if file exists at key: variants/assets/images/000/000/057/original/HOMEpg_PromoProd_990x660_microsite-Xplory.png/571109d233f5604a00cda0d8b8112d86e0bda9ff3c03f83cd9b25edbaf2dbed8 (no)
S3 Storage (320.9ms) Downloaded file from key: assets/images/000/000/057/original/HOMEpg_PromoProd_990x660_microsite-Xplory.png
Completed 500 Internal Server Error in 374ms (ActiveRecord: 0.6ms | Allocations: 29916)
ActiveStorage::IntegrityError (ActiveStorage::IntegrityError):
activestorage (6.0.2.1) lib/active_storage/downloader.rb:39:in `verify_integrity_of'
activestorage (6.0.2.1) lib/active_storage/downloader.rb:14:in `block in open'
activestorage (6.0.2.1) lib/active_storage/downloader.rb:24:in `open_tempfile'
activestorage (6.0.2.1) lib/active_storage/downloader.rb:12:in `open'
activestorage (6.0.2.1) lib/active_storage/service.rb:86:in `open'
activestorage (6.0.2.1) app/models/active_storage/blob.rb:219:in `open'
activestorage (6.0.2.1) app/models/active_storage/variant.rb:99:in `process'
activestorage (6.0.2.1) app/models/active_storage/variant.rb:67:in `processed'
activestorage (6.0.2.1) app/controllers/active_storage/representations_controller.rb:12:in `show'
actionpack (6.0.2.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.2.1) lib/abstract_controller/base.rb:196:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.2.1) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.2.1) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (6.0.2.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.2.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.2.1) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.2.1) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.2.1) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.2.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.2.1) lib/abstract_controller/base.rb:136:in `process'
actionview (6.0.2.1) lib/action_view/rendering.rb:39:in `process'
actionpack (6.0.2.1) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (6.0.2.1) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:51:in `dispatch'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.2.1) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.2.1) lib/action_dispatch/routing/route_set.rb:837:in `call'
rack (2.1.2) lib/rack/tempfile_reaper.rb:17:in `call'
rack (2.1.2) lib/rack/etag.rb:27:in `call'
rack (2.1.2) lib/rack/conditional_get.rb:27:in `call'
rack (2.1.2) lib/rack/head.rb:14:in `call'
actionpack (6.0.2.1) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.1.2) lib/rack/session/abstract/id.rb:269:in `context'
rack (2.1.2) lib/rack/session/abstract/id.rb:263:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.2.1) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.2.1) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (6.0.2.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.0.1) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.0.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `catch'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.2.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.2.1) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.2.1) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
request_store (1.5.0) lib/request_store/middleware.rb:19:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.1.2) lib/rack/method_override.rb:24:in `call'
rack (2.1.2) lib/rack/runtime.rb:24:in `call'
activesupport (6.0.2.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.1.2) lib/rack/sendfile.rb:113:in `call'
actionpack (6.0.2.1) lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
webpacker (4.2.2) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.2.1) lib/rails/engine.rb:526:in `call'
puma (3.12.2) lib/puma/configuration.rb:227:in `call'
puma (3.12.2) lib/puma/server.rb:674:in `handle_request'
puma (3.12.2) lib/puma/server.rb:476:in `process_client'
puma (3.12.2) lib/puma/server.rb:334:in `block in run'
puma (3.12.2) lib/puma/thread_pool.rb:135:in `block in spawn_thread'
I researched IntegrityError a but and understand what is is about but that's it.
So first of all I'd like to understand what happens here and why variants are broken.
Second I would like to know if I can remedy that in some way...
I use vips but I uncommented it and it didn't change anything.

will_paginate mistaking a relation for an array

Rails 5 application with will_paginate has the following log entry:
Usercontent Load (0.7ms) SELECT "usercontents".* FROM "usercontents" WHERE (id IN (171,172,33,34,35,156,173,144,78,81,88,90,93,96,36,37,38,48,87,89,94,39,175,176) AND contenttype_id = 1)
↳ app/controllers/travels_controller.rb:45
and the controller action specifies
#points = Usercontent.where('id IN (?) AND contenttype_id = ?', #all_valid_usercontents, 1).paginate(page: params[:page], per_page: 18)
if I run in the console that line as
#points = Usercontent.where('id IN (?) AND contenttype_id = ?', [171,172,33,34,35,156,173,144,78,81,88,90,93,96,36,37,38,48,87,89,94,39,175,176], 1).paginate(page: 1, per_page: 18)
then
> #points.class
=> Usercontent::ActiveRecord_Relation
Inserting in the controller debugging points:
Rails.logger.info #a_points.class
Rails.logger.info #points.class
returns
Usercontent::ActiveRecord_Relation
Usercontent::ActiveRecord_Relation
View
<div id='yield_pcontent'>
<%= render 'points' %>
</div>
<div id="infinite-scrolling">
<%= will_paginate %>
</div>
partial _points.html.erb
<div id=points class='tableize'>
<%= render partial: 'point', collection: #points %>
</div>
How can will_paginate thus recognize helper <%= will_paginate %> as an array
undefined method `total_pages' for #<Array:0x00007f9a27d47718>
note: adding require 'will_paginate/array' does not change this behaviour
update
activerecord (5.2.3) lib/active_record/relation/delegation.rb:125:in `method_missing'
will_paginate (3.1.7) lib/will_paginate/view_helpers.rb:73:in `will_paginate'
will_paginate (3.1.7) lib/will_paginate/view_helpers/action_view.rb:33:in `will_paginate'
app/views/travels/_region_points.html.erb:5:in `_app_views_travels__region_points_html_erb__2375899185333558082_70150028432340'
actionview (5.2.3) lib/action_view/template.rb:159:in `block in render'
activesupport (5.2.3) lib/active_support/notifications.rb:170:in `instrument'
actionview (5.2.3) lib/action_view/template.rb:354:in `instrument_render_template'
actionview (5.2.3) lib/action_view/template.rb:157:in `render'
actionview (5.2.3) lib/action_view/renderer/partial_renderer.rb:344:in `block in render_partial'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
actionview (5.2.3) lib/action_view/renderer/partial_renderer.rb:333:in `render_partial'
actionview (5.2.3) lib/action_view/renderer/partial_renderer.rb:312:in `render'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:49:in `render_partial'
actionview (5.2.3) lib/action_view/helpers/rendering_helper.rb:36:in `render'
app/views/travels/cc.html.erb:33:in `_app_views_travels_cc_html_erb___2132430413937746159_70149902220280'
actionview (5.2.3) lib/action_view/template.rb:159:in `block in render'
activesupport (5.2.3) lib/active_support/notifications.rb:170:in `instrument'
actionview (5.2.3) lib/action_view/template.rb:354:in `instrument_render_template'
actionview (5.2.3) lib/action_view/template.rb:157:in `render'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:44:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.2.3) lib/action_view/renderer/abstract_renderer.rb:43:in `instrument'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (5.2.3) lib/action_view/renderer/template_renderer.rb:16:in `render'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:44:in `render_template'
actionview (5.2.3) lib/action_view/renderer/renderer.rb:25:in `render'
actionview (5.2.3) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.2.3) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionview (5.2.3) lib/action_view/rendering.rb:84:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.2.3) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (5.2.3) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/home/jerdvo/.rbenv/versions/2.6.1/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
activesupport (5.2.3) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:31:in `cleanup_view_runtime'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:45:in `render'
wicked_pdf (1.2.2) lib/wicked_pdf/pdf_helper.rb:46:in `call'
wicked_pdf (1.2.2) lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
wicked_pdf (1.2.2) lib/wicked_pdf/pdf_helper.rb:30:in `render'
app/controllers/travels_controller.rb:59:in `cc'
actionpack (5.2.3) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:194:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (5.2.3) lib/active_support/callbacks.rb:132:in `run_callbacks'
actionpack (5.2.3) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `block in instrument'
activesupport (5.2.3) lib/active_support/notifications/instrumenter.rb:23:in `instrument'
activesupport (5.2.3) lib/active_support/notifications.rb:168:in `instrument'
actionpack (5.2.3) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (5.2.3) lib/action_controller/metal/params_wrapper.rb:256:in `process_action'
activerecord (5.2.3) lib/active_record/railties/controller_runtime.rb:24:in `process_action'
actionpack (5.2.3) lib/abstract_controller/base.rb:134:in `process'
actionview (5.2.3) lib/action_view/rendering.rb:32:in `process'
actionpack (5.2.3) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (5.2.3) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:52:in `dispatch'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:34:in `serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:52:in `block in serve'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `each'
actionpack (5.2.3) lib/action_dispatch/journey/router.rb:35:in `serve'
actionpack (5.2.3) lib/action_dispatch/routing/route_set.rb:840:in `call'
warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
warden (1.2.8) lib/warden/manager.rb:34:in `catch'
warden (1.2.8) lib/warden/manager.rb:34:in `call'
rack (2.0.7) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.0.7) lib/rack/etag.rb:25:in `call'
rack (2.0.7) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.7) lib/rack/head.rb:12:in `call'
actionpack (5.2.3) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.0.7) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.7) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/cookies.rb:670:in `call'
activerecord (5.2.3) lib/active_record/migration.rb:559:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (5.2.3) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (5.2.3) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:61:in `call'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:22:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (5.2.3) lib/rails/rack/logger.rb:38:in `call_app'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `block in tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (5.2.3) lib/active_support/tagged_logging.rb:71:in `tagged'
railties (5.2.3) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.0.7) lib/rack/method_override.rb:22:in `call'
rack (2.0.7) lib/rack/runtime.rb:22:in `call'
activesupport (5.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (5.2.3) lib/action_dispatch/middleware/static.rb:127:in `call'
rack (2.0.7) lib/rack/sendfile.rb:111:in `call'
railties (5.2.3) lib/rails/engine.rb:524:in `call'
/usr/lib/ruby/vendor_ruby/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:149:in `accept_and_process_next_request'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler/thread_handler.rb:110:in `main_loop'
/usr/lib/ruby/vendor_ruby/phusion_passenger/request_handler.rb:415:in `block (3 levels) in start_threads'
/usr/lib/ruby/vendor_ruby/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
Update 2
based on a suggestion, two behaviours are being observed:
<%= will_paginate %> => undefined method `total_pages' for #<Array:0x00007f9a261e2540>
<%= will_paginate #points %> => undefined method `total_pages' for #<Usercontent::ActiveRecord_Relation:0x00007f9a26d07ab0>
He is waiting for an Object, not an Array. I share my solution, adapt it to your case.
def render_partial_resource(resources)
if resources.present?
if resources.respond_to?(:model_name)
folder = resources.model_name.name.pluralize.downcase
partial = resources.model_name.name.downcase
else
folder = resources.object.name.pluralize.downcase
partial = resources.object.name.downcase
end
resources.map do |resource|
render partial:"#{folder}/#{partial}", locals:{"#{partial}": resource}
end.join(" ").html_safe
end
end

Rails i18n and EasyTranslate

I am using a locale :cn which is not recognized by EasyTranslate. I am trying to create the if in the controller such as:
def index
#events = Events.all
if I18n.locale == :cn
#locale = ":zh-CN"
else
#locale = I18n.locale
end
end
so that I can use the following in my view:
<%= check_box_tag "by_cities[]", city %> <%= EasyTranslate.translate(city, :to => #locale, :key => #key) %>
BUt I get an EasyTranslate:EasyTranslateException in Event#index Invalid Value
How can i get EasyTranslate to take the new locale just for this method please?
Thank you
Et
Application Trace | Framework Trace | Full Trace
easy_translate (0.5.1) lib/easy_translate/request.rb:47:in `perform_raw'
easy_translate (0.5.1) lib/easy_translate/translation.rb:34:in `request_translations'
easy_translate (0.5.1) lib/easy_translate/threadable.rb:24:in `block in threaded_process'
easy_translate (0.5.1) lib/easy_translate/threadable.rb:24:in `map'
easy_translate (0.5.1) lib/easy_translate/threadable.rb:24:in `threaded_process'
easy_translate (0.5.1) lib/easy_translate/translation.rb:20:in `translate'
app/views/events/index.html.erb:21:in `block (2 levels) in _app_views_events_index_html_erb___49110152348777287_70221206769120'
app/views/events/index.html.erb:19:in `each'
app/views/events/index.html.erb:19:in `block in _app_views_events_index_html_erb___49110152348777287_70221206769120'
actionview (5.1.6) lib/action_view/helpers/capture_helper.rb:39:in `block in capture'
actionview (5.1.6) lib/action_view/helpers/capture_helper.rb:203:in `with_output_buffer'
actionview (5.1.6) lib/action_view/helpers/capture_helper.rb:39:in `capture'
actionview (5.1.6) lib/action_view/helpers/form_tag_helper.rb:70:in `form_tag'
app/views/events/index.html.erb:15:in `_app_views_events_index_html_erb___49110152348777287_70221206769120'
actionview (5.1.6) lib/action_view/template.rb:157:in `block in render'
activesupport (5.1.6) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.1.6) lib/action_view/template.rb:352:in `instrument_render_template'
actionview (5.1.6) lib/action_view/template.rb:155:in `render'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:52:in `block (2 levels) in render_template'
actionview (5.1.6) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionview (5.1.6) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:51:in `block in render_template'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:59:in `render_with_layout'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:50:in `render_template'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (5.1.6) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (5.1.6) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (5.1.6) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.1.6) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (5.1.6) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.1.6) lib/action_controller/metal/renderers.rb:141:in `render_to_body'
actionpack (5.1.6) lib/abstract_controller/rendering.rb:24:in `render'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (5.1.6) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/Users/etienne/.rvm/rubies/ruby-2.5.0/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
activesupport (5.1.6) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
searchkick (3.1.2) lib/searchkick/logging.rb:214:in `cleanup_view_runtime'
activerecord (5.1.6) lib/active_record/railties/controller_runtime.rb:29:in `cleanup_view_runtime'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:43:in `render'
wicked_pdf (1.1.0) lib/wicked_pdf/pdf_helper.rb:42:in `render_with_wicked_pdf'
wicked_pdf (1.1.0) lib/wicked_pdf/pdf_helper.rb:27:in `render'
actionpack (5.1.6) lib/action_controller/metal/implicit_render.rb:33:in `default_render'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `block in send_action'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `tap'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:186:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.1.6) lib/active_support/callbacks.rb:131:in `run_callbacks'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
searchkick (3.1.2) lib/searchkick/logging.rb:209:in `process_action'
activerecord (5.1.6) lib/active_record/railties/controller_runtime.rb:22:in `process_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:124:in `process'
actionview (5.1.6) lib/action_view/rendering.rb:30:in `process'
actionpack (5.1.6) lib/action_controller/metal.rb:189:in `dispatch'
actionpack (5.1.6) lib/action_controller/metal.rb:253:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:31:in `serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:844:in `call'
warden (1.2.8) lib/warden/manager.rb:36:in `block in call'
warden (1.2.8) lib/warden/manager.rb:34:in `catch'
warden (1.2.8) lib/warden/manager.rb:34:in `call'
rack (2.0.6) lib/rack/etag.rb:25:in `call'
rack (2.0.6) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.6) lib/rack/head.rb:12:in `call'
rack (2.0.6) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.6) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.1.6) lib/active_record/migration.rb:556:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.6) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
rollbar (2.18.0) lib/rollbar/middleware/rails/rollbar.rb:24:in `block in call'
rollbar (2.18.0) lib/rollbar.rb:146:in `scoped'
rollbar (2.18.0) lib/rollbar/middleware/rails/rollbar.rb:22:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
rollbar (2.18.0) lib/rollbar/middleware/rails/show_exceptions.rb:22:in `call_with_rollbar'
web-console (3.7.0) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.7.0) lib/web_console/middleware.rb:22:in `block in call'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `catch'
web-console (3.7.0) lib/web_console/middleware.rb:20:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.6) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
request_store (1.4.1) lib/request_store/middleware.rb:19:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.6) lib/rack/method_override.rb:22:in `call'
rack (2.0.6) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.6) lib/rack/sendfile.rb:111:in `call'
railties (5.1.6) lib/rails/engine.rb:522:in `call'
puma (3.12.0) lib/puma/configuration.rb:225:in `call'
puma (3.12.0) lib/puma/server.rb:658:in `handle_request'
puma (3.12.0) lib/puma/server.rb:472:in `process_client'
puma (3.12.0) lib/puma/server.rb:332:in `block in run'
puma (3.12.0) lib/puma/thread_pool.rb:133:in `block in spawn_thread'
Very simple actually :
In the controller :
if I18n.locale == :cn
#locale ="zh-CN"
else
#locale = (":"+ (I18n.locale).to_s)
end
In the view:
<%= check_box_tag "by_cities[]", city %> <%= EasyTranslate.translate(city, :to => #locale, :key => #key) %>

Shoppe and kaminari - undefined method `entry_name' for #<ActiveRecord::Relation []> for #orders

I've been working with the shoppe gem, and I'm currently completely stumped by an error I'm getting when I'm opening up the orders page of the admin panel.
I'm using version 1.0.7 because product variants broke on the subsequent ones. Everything was working completely fine until I merged with a different branch in my repo, and now when I try to access the orders page of the admin panel this happens:
ActionView::Template::Error (undefined method `entry_name' for #<ActiveRecord::Relation []>):
6: = link_to t('shoppe.orders.search_orders'), '#', :class => 'button', :rel => 'searchOrders'
7: %h2.orders
8: = t('shoppe.orders.orders')
9: %span= page_entries_info #orders
10:
11: = render 'search_form'
12:
activerecord (4.2.4) lib/active_record/relation/delegation.rb:136:in `method_missing'
activerecord (4.2.4) lib/active_record/relation/delegation.rb:99:in `method_missing'
kaminari (0.16.3) lib/kaminari/helpers/action_view_extension.rb:92:in `page_entries_info'
shoppe (1.0.7) app/views/shoppe/orders/index.html.haml:9:in `block in ___sers_aur______rvm_gems_ruby_______gems_shoppe_______app_views_shoppe_orders_index_html_haml__4424402014120534252_70189058436720'
haml (4.0.7) lib/haml/helpers.rb:368:in `call'
haml (4.0.7) lib/haml/helpers.rb:368:in `block in capture_haml'
haml (4.0.7) lib/haml/helpers.rb:608:in `with_haml_buffer'
haml (4.0.7) lib/haml/helpers.rb:364:in `capture_haml'
haml (4.0.7) lib/haml/helpers/xss_mods.rb:61:in `capture_haml_with_haml_xss'
haml (4.0.7) lib/haml/helpers/action_view_mods.rb:45:in `capture_with_haml'
actionview (4.2.4) lib/action_view/helpers/capture_helper.rb:152:in `content_for'
shoppe (1.0.7) app/views/shoppe/orders/index.html.haml:3:in `___sers_aur______rvm_gems_ruby_______gems_shoppe_______app_views_shoppe_orders_index_html_haml__4424402014120534252_70189058436720'
actionview (4.2.4) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.4) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.4) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.4) lib/action_view/template.rb:143:in `render'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (4.2.4) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.4) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.4) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.4) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.2.4) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.2.4) lib/action_view/rendering.rb:100:in `_render_template'
actionpack (4.2.4) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.2.4) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (4.2.4) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.2.4) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.4) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.4) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (4.2.4) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/Users/aur2103/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
activesupport (4.2.4) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (4.2.4) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:43:in `render'
actionpack (4.2.4) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.2.4) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.2.4) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.4) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.4) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
activesupport (4.2.4) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.4) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
activesupport (4.2.4) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
activesupport (4.2.4) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.4) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.4) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.4) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.4) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.4) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.4) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.4) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.4) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.4) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.4) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.4) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:76:in `call'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:76:in `dispatch'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:45:in `serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:821:in `call'
railties (4.2.4) lib/rails/engine.rb:518:in `call'
railties (4.2.4) lib/rails/railtie.rb:194:in `public_send'
railties (4.2.4) lib/rails/railtie.rb:194:in `method_missing'
actionpack (4.2.4) lib/action_dispatch/routing/mapper.rb:51:in `serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.4) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.4) lib/action_dispatch/routing/route_set.rb:821:in `call'
shoppe (1.0.7) lib/shoppe/settings_loader.rb:10:in `call'
nifty-attachments (1.0.4) lib/nifty/attachments/middleware.rb:23:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.6.4) lib/rack/etag.rb:24:in `call'
rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
rack (1.6.4) lib/rack/head.rb:13:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/flash.rb:260:in `call'
rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.4) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.4) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
activerecord (4.2.4) lib/active_record/migration.rb:377:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.4) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.4) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.4) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.4) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.4) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.4) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.4) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.4) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
rack (1.6.4) lib/rack/runtime.rb:18:in `call'
activesupport (4.2.4) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
actionpack (4.2.4) lib/action_dispatch/middleware/static.rb:116:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.4) lib/rails/engine.rb:518:in `call'
railties (4.2.4) lib/rails/application.rb:165:in `call'
rack (1.6.4) lib/rack/lock.rb:17:in `call'
rack (1.6.4) lib/rack/content_length.rb:15:in `call'
rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
/Users/aur2103/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
/Users/aur2103/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
/Users/aur2103/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'
I know that this is happening in the page_entries_info method in kaminari. This one, specifically the second line within the method:
def page_entries_info(collection, options = {})
entry_name = options[:entry_name] || collection.entry_name
entry_name = entry_name.pluralize unless collection.total_count == 1
if collection.total_pages < 2
t('helpers.page_entries_info.one_page.display_entries', :entry_name => entry_name, :count => collection.total_count)
else
first = collection.offset_value + 1
last = collection.last_page? ? collection.total_count : collection.offset_value + collection.limit_value
t('helpers.page_entries_info.more_pages.display_entries', :entry_name => entry_name, :first => first, :last => last, :total => collection.total_count)
end.html_safe
end
The strange thing is, I've put in some print statements in both the functioning version and the broken version, and in BOTH of them options[:entry_name] is nil and collection.inspect prints out #<ActiveRecord::Relation []>. However, only the newly merged version throws the error. Why does #<ActiveRecord::Relation []> not have this method in only one of the branches? What could be causing this?
Are you using will_paginate or bootstrap-will_paginate ?
Please see here: https://github.com/tryshoppe/shoppe/issues/189
I will also suggest the following:
1. Kill your rails server
2. type "spring stop"
3. bundle/restart rails
I had this same issue with entry_name without using will_paginate so the second fix worked for me.
Explicitly declaring entry_name in the line that calls page_entries_info is what solved it for me.
<%= page_entries_info #orders, entry_name: "order" =>
See the solution here.

Resources