Render and cache a heterogenous collection in Rails 5 - ruby-on-rails

I'm working on an activity stream and have an Event model with subclasses for each type of event, such as StatusChanged etc.
Each type of event has a corresponding partial that formats the event for rendering.
Rails can render heterogenous collections in this manner, and its working out just fine until I try to cache the collection with the cached: true option on the render call.
Here's what I'm working on:
= render partial: events, as: :event, cached: true
where events is the heterogenous collection.
I've also overridden the to_partial_path on event so that partials can be stored in events/_event_type.html.haml vs events/event_type/_event_type.html.haml:
# Render partials from events/_<type> rather than default events/<type>/_<type>
def to_partial_path
self.class.name.underscore
end
Here's the top of the stack trace for the issue I'm running into:
NoMethodError - undefined method `virtual_path' for nil:NilClass:
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer/collection_caching.rb:35:in `expanded_cache_key'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer/collection_caching.rb:30:in `block in collection_by_cache_keys'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer/collection_caching.rb:29:in `collection_by_cache_keys'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer/collection_caching.rb:15:in `cache_collection_render'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer.rb:326:in `block in render_collection'
actionview (5.0.0.1) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `instrument'
actionview (5.0.0.1) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer.rb:319:in `render_collection'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer.rb:308:in `render'
actionview (5.0.0.1) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionview (5.0.0.1) lib/action_view/renderer/renderer.rb:21:in `render'
actionview (5.0.0.1) lib/action_view/helpers/rendering_helper.rb:32:in `render'
haml (4.0.7) lib/haml/helpers/action_view_mods.rb:10:in `block in render_with_haml'
haml (4.0.7) lib/haml/helpers.rb:89:in `non_haml'
haml (4.0.7) lib/haml/helpers/action_view_mods.rb:10:in `render_with_haml'
app/views/job_applications/_activity.html.haml:7:in `_app_views_job_applications__activity_html_haml__883799091596117587_70254600015120'
actionview (5.0.0.1) lib/action_view/template.rb:158:in `block in render'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `instrument'
actionview (5.0.0.1) lib/action_view/template.rb:348:in `instrument'
actionview (5.0.0.1) lib/action_view/template.rb:156:in `render'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer.rb:343:in `render_partial'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer.rb:311:in `block in render'
actionview (5.0.0.1) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `instrument'
actionview (5.0.0.1) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer.rb:310:in `render'
actionview (5.0.0.1) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionview (5.0.0.1) lib/action_view/renderer/renderer.rb:21:in `render'
actionview (5.0.0.1) lib/action_view/helpers/rendering_helper.rb:32:in `render'
haml (4.0.7) lib/haml/helpers/action_view_mods.rb:10:in `block in render_with_haml'
haml (4.0.7) lib/haml/helpers.rb:89:in `non_haml'
haml (4.0.7) lib/haml/helpers/action_view_mods.rb:10:in `render_with_haml'
app/views/job_applications/_edit.html.haml:29:in `_app_views_job_applications__edit_html_haml__4043825476406280496_70254604867100'
actionview (5.0.0.1) lib/action_view/template.rb:158:in `block in render'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `instrument'
actionview (5.0.0.1) lib/action_view/template.rb:348:in `instrument'
actionview (5.0.0.1) lib/action_view/template.rb:156:in `render'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer.rb:343:in `render_partial'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer.rb:311:in `block in render'
actionview (5.0.0.1) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.1) lib/active_support/notifications.rb:164:in `instrument'
actionview (5.0.0.1) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
actionview (5.0.0.1) lib/action_view/renderer/partial_renderer.rb:310:in `render'
actionview (5.0.0.1) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionview (5.0.0.1) lib/action_view/renderer/renderer.rb:21:in `render'
actionview (5.0.0.1) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.0.0.1) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (5.0.0.1) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (5.0.0.1) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.0.0.1) lib/action_controller/metal/renderers.rb:144:in `render_to_body'
actionpack (5.0.0.1) lib/abstract_controller/rendering.rb:26:in `render'
Digging into lib/action_view/renderer/partial_renderer/collection_caching.rb:35 it looks like #template is nil.
Its also notable that this issue did not come up while the collection had only one type of Event in it. As soon as the collection contained two types of events...boom.
Has anyone run into this before? It might be as straightforward as "You can't cache a heterogenous collection in this way".

Related

Undefined method 'id' error using collection_select with form_for in Ruby on Rails

I'm having an issue with collection_select using form_for in rails. This issue is coming from a method that was working until I namespaced my routes to be only for admin. The admin routes are working as they should as far as I can tell, but it is the only connection I can find to why this method stopped working.
Error:
undefined method `id' for #<Array:0x00007faf084c7048>
Here is the trace if that would help:
actionview (6.1.3.2) lib/action_view/helpers/tags/base.rb:41:in `public_send'
actionview (6.1.3.2) lib/action_view/helpers/tags/base.rb:41:in `value'
actionview (6.1.3.2) lib/action_view/helpers/tags/collection_select.rb:18:in `block in render'
actionview (6.1.3.2) lib/action_view/helpers/tags/collection_select.rb:18:in `fetch'
actionview (6.1.3.2) lib/action_view/helpers/tags/collection_select.rb:18:in `render'
actionview (6.1.3.2) lib/action_view/helpers/form_options_helper.rb:203:in `collection_select'
actionview (6.1.3.2) lib/action_view/helpers/form_options_helper.rb:835:in `collection_select'
app/views/admin/users/_edit_my_profile.html.erb:28
actionview (6.1.3.2) lib/action_view/helpers/capture_helper.rb:45:in `block in capture'
actionview (6.1.3.2) lib/action_view/helpers/capture_helper.rb:209:in `with_output_buffer'
actionview (6.1.3.2) lib/action_view/helpers/capture_helper.rb:45:in `capture'
actionview (6.1.3.2) lib/action_view/helpers/form_helper.rb:1004:in `fields_for'
actionview (6.1.3.2) lib/action_view/helpers/form_helper.rb:2195:in `fields_for'
app/views/admin/users/_edit_my_profile.html.erb:16
actionview (6.1.3.2) lib/action_view/helpers/capture_helper.rb:45:in `block in capture'
actionview (6.1.3.2) lib/action_view/helpers/capture_helper.rb:209:in `with_output_buffer'
actionview (6.1.3.2) lib/action_view/helpers/capture_helper.rb:45:in `capture'
actionview (6.1.3.2) lib/action_view/helpers/form_helper.rb:450:in `form_for'
app/views/admin/users/_edit_my_profile.html.erb:3
actionview (6.1.3.2) lib/action_view/base.rb:247:in `public_send'
actionview (6.1.3.2) lib/action_view/base.rb:247:in `_run'
actionview (6.1.3.2) lib/action_view/template.rb:154:in `block in render'
activesupport (6.1.3.2) lib/active_support/notifications.rb:205:in `instrument'
actionview (6.1.3.2) lib/action_view/template.rb:345:in `instrument_render_template'
actionview (6.1.3.2) lib/action_view/template.rb:152:in `render'
actionview (6.1.3.2) lib/action_view/renderer/partial_renderer.rb:285:in `block in render_partial_template'
activesupport (6.1.3.2) lib/active_support/notifications.rb:203:in `block in instrument'
activesupport (6.1.3.2) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.1.3.2) lib/active_support/notifications.rb:203:in `instrument'
actionview (6.1.3.2) lib/action_view/renderer/partial_renderer.rb:280:in `render_partial_template'
actionview (6.1.3.2) lib/action_view/renderer/partial_renderer.rb:271:in `render'
actionview (6.1.3.2) lib/action_view/renderer/renderer.rb:81:in `render_partial_to_object'
actionview (6.1.3.2) lib/action_view/renderer/renderer.rb:27:in `render_to_object'
actionview (6.1.3.2) lib/action_view/renderer/renderer.rb:22:in `render'
actionview (6.1.3.2) lib/action_view/helpers/rendering_helper.rb:38:in `block in render'
actionview (6.1.3.2) lib/action_view/base.rb:273:in `in_rendering_context'
actionview (6.1.3.2) lib/action_view/helpers/rendering_helper.rb:34:in `render'
app/views/admin/users/profile.html.erb:14
actionview (6.1.3.2) lib/action_view/base.rb:247:in `public_send'
actionview (6.1.3.2) lib/action_view/base.rb:247:in `_run'
actionview (6.1.3.2) lib/action_view/template.rb:154:in `block in render'
activesupport (6.1.3.2) lib/active_support/notifications.rb:205:in `instrument'
actionview (6.1.3.2) lib/action_view/template.rb:345:in `instrument_render_template'
actionview (6.1.3.2) lib/action_view/template.rb:152:in `render'
actionview (6.1.3.2) lib/action_view/renderer/template_renderer.rb:61:in `block (2 levels) in render_template'
activesupport (6.1.3.2) lib/active_support/notifications.rb:203:in `block in instrument'
activesupport (6.1.3.2) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.1.3.2) lib/active_support/notifications.rb:203:in `instrument'
actionview (6.1.3.2) lib/action_view/renderer/template_renderer.rb:56:in `block in render_template'
actionview (6.1.3.2) lib/action_view/renderer/template_renderer.rb:71:in `block in render_with_layout'
activesupport (6.1.3.2) lib/active_support/notifications.rb:203:in `block in instrument'
activesupport (6.1.3.2) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.1.3.2) lib/active_support/notifications.rb:203:in `instrument'
actionview (6.1.3.2) lib/action_view/renderer/template_renderer.rb:70:in `render_with_layout'
actionview (6.1.3.2) lib/action_view/renderer/template_renderer.rb:55:in `render_template'
actionview (6.1.3.2) lib/action_view/renderer/template_renderer.rb:11:in `render'
actionview (6.1.3.2) lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
actionview (6.1.3.2) lib/action_view/renderer/renderer.rb:29:in `render_to_object'
actionview (6.1.3.2) lib/action_view/rendering.rb:117:in `block in _render_template'
actionview (6.1.3.2) lib/action_view/base.rb:273:in `in_rendering_context'
actionview (6.1.3.2) lib/action_view/rendering.rb:116:in `_render_template'
actionpack (6.1.3.2) lib/action_controller/metal/streaming.rb:218:in `_render_template'
actionview (6.1.3.2) lib/action_view/rendering.rb:103:in `render_to_body'
actionpack (6.1.3.2) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (6.1.3.2) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (6.1.3.2) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (6.1.3.2) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (6.1.3.2) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
/home/taylor/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
activesupport (6.1.3.2) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (6.1.3.2) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
actionpack (6.1.3.2) lib/action_controller/metal/instrumentation.rb:86:in `cleanup_view_runtime'
activerecord (6.1.3.2) lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
actionpack (6.1.3.2) lib/action_controller/metal/instrumentation.rb:45:in `render'
actionpack (6.1.3.2) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
actionpack (6.1.3.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (6.1.3.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (6.1.3.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.1.3.2) lib/abstract_controller/base.rb:228:in `process_action'
actionpack (6.1.3.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.1.3.2) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.1.3.2) lib/active_support/callbacks.rb:117:in `block in run_callbacks'
actiontext (6.1.3.2) lib/action_text/rendering.rb:20:in `with_renderer'
actiontext (6.1.3.2) lib/action_text/engine.rb:55:in `block (4 levels) in <class:Engine>'
activesupport (6.1.3.2) lib/active_support/callbacks.rb:126:in `instance_exec'
activesupport (6.1.3.2) lib/active_support/callbacks.rb:126:in `block in run_callbacks'
activesupport (6.1.3.2) lib/active_support/callbacks.rb:137:in `run_callbacks'
actionpack (6.1.3.2) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.1.3.2) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.1.3.2) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (6.1.3.2) lib/active_support/notifications.rb:203:in `block in instrument'
activesupport (6.1.3.2) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.1.3.2) lib/active_support/notifications.rb:203:in `instrument'
actionpack (6.1.3.2) lib/action_controller/metal/instrumentation.rb:33:in `process_action'
actionpack (6.1.3.2) lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
activerecord (6.1.3.2) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.1.3.2) lib/abstract_controller/base.rb:165:in `process'
actionview (6.1.3.2) lib/action_view/rendering.rb:39:in `process'
actionpack (6.1.3.2) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.1.3.2) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.1.3.2) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.1.3.2) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.1.3.2) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (6.1.3.2) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.1.3.2) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.1.3.2) lib/action_dispatch/routing/route_set.rb:842: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.1.3.2) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
actionpack (6.1.3.2) 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.1.3.2) lib/action_dispatch/middleware/cookies.rb:689:in `call'
activerecord (6.1.3.2) lib/active_record/migration.rb:601:in `call'
actionpack (6.1.3.2) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.1.3.2) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (6.1.3.2) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.1.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.3.2) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
actionpack (6.1.3.2) lib/action_dispatch/middleware/debug_exceptions.rb:29: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:28: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.1.3.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.1.3.2) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.1.3.2) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.1.3.2) lib/active_support/tagged_logging.rb:99:in `block in tagged'
activesupport (6.1.3.2) lib/active_support/tagged_logging.rb:37:in `tagged'
activesupport (6.1.3.2) lib/active_support/tagged_logging.rb:99:in `tagged'
railties (6.1.3.2) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.1.3.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.1.3.2) lib/action_dispatch/middleware/request_id.rb:26:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (6.1.3.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.1.3.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.3.2) lib/action_dispatch/middleware/static.rb:24:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.1.3.2) lib/action_dispatch/middleware/host_authorization.rb:98:in `call'
webpacker (5.4.0) lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.1.3.2) lib/rails/engine.rb:539:in `call'
puma (5.3.2) lib/puma/configuration.rb:249:in `call'
puma (5.3.2) lib/puma/request.rb:77:in `block in handle_request'
puma (5.3.2) lib/puma/thread_pool.rb:338:in `with_force_shutdown'
puma (5.3.2) lib/puma/request.rb:76:in `handle_request'
puma (5.3.2) lib/puma/server.rb:438:in `process_client'
puma (5.3.2) lib/puma/thread_pool.rb:145:in `block in spawn_thread'
Here is the full method:
<%= user_builder.fields_for :team_attributes, [:admin, #team] do |team_builder| %>
<%= team_builder.hidden_field :profile, :value => "profile" %>
<% if #company.teams.all == [] %>
<br><h3>Create a New Team:</h3>
Team Name: <%= team_builder.text_field :name %>
Team Description: <%= team_builder.text_area :description %><br><br>
<% else %>
<% if #show_form == "new-position" %>
Change Team: <%= team_builder.collection_select :id, #company.teams, :id, :name, {:include_blank => true} %>
Or <%= link_to "Create a new Team", "/admin/profile/#{#user.id}/edit/new-team-and-new-position" %><br><br>
<% elsif #show_form == "new-team" %>
<% else %>
Change Team: <%= team_builder.collection_select :id, #company.teams, :id, :name, {:include_blank => true} %>
Or <%= link_to "Create a new Team", "/admin/profile/#{#user.id}/edit/new-team" %><br><br>
<% end %>
<% end %>
The error is being throw here:
Change Team: <%= team_builder.collection_select :id, #company.teams, :id, :name, {:include_blank => true} %>
I threw in a pry and returned the value of #company and the value of #company.teams:
#<Company:0x00007faf085aa668
id: 1,
name: "My Company",
industry: "Retail",
address: "1546 Jefferson Dr.",
city: "Townesville",
state: "AA",
phone_number: "1232345678",
email: "info#info.com",
user_id: 1,
created_at: Mon, 07 Jun 2021 22:31:22.169619000 UTC +00:00,
updated_at: Mon, 07 Jun 2021 22:31:22.169619000 UTC +00:00>
[#<Team:0x00007faf00375170
id: 2,
name: "Marketing",
description:
"Develops and implements marketing campaigns from previously developed strategies.",
company_id: 1,
user_id: 1,
created_at: Mon, 07 Jun 2021 22:52:15.767441000 UTC +00:00,
updated_at: Mon, 07 Jun 2021 22:52:15.767441000 UTC +00:00>]
This is attempting to create a drop down of a company's team dependent on if the company has teams and depending on what links the user has clicked to reveal parts of the full form. Basically this error is preventing some substantial functionality and progress towards completing this application. If anyone needs more information to help please let me know. Thanks for the help.
Solved it :/ there was no need for me to namespace #teams in fields_for when the original form_for was already namespaced. Don't go to fast people lol

Can't seem to get hotwire-rails `turbo_stream_from` working

I installed the hotwire-rails gem and run rails hotwire:install, which seems to work fine.
When I call the method turbo_stream_from "posts" from a view, I receive the following error, which I don't understand at all.
undefined method `then' for "posts":String
In multiple examples I see a string being passed to the method turbo_stream_from, to identify the streamname. I tried checking the repo but I didn't find much based upon my knowledge of what I saw. Does anybody know what pieces I might be missing to get this working?
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:21:in `stream_name_from'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:19:in `block in stream_name_from'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:19:in `map'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:19:in `stream_name_from'
turbo-rails (0.5.1) app/channels/turbo/streams/stream_name.rb:13:in `signed_stream_name'
turbo-rails (0.5.1) app/helpers/turbo/streams_helper.rb:20:in `turbo_stream_from'
app/views/forms/index.html.haml:6
actionview (6.0.3.5) lib/action_view/base.rb:274:in `_run'
actionview (6.0.3.5) lib/action_view/template.rb:185:in `block in render'
activesupport (6.0.3.5) lib/active_support/notifications.rb:182:in `instrument'
actionview (6.0.3.5) lib/action_view/template.rb:385:in `instrument_render_template'
actionview (6.0.3.5) lib/action_view/template.rb:183:in `render'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:58:in `block (2 levels) in render_template'
actionview (6.0.3.5) lib/action_view/renderer/abstract_renderer.rb:88:in `block in instrument'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.5) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `instrument'
actionview (6.0.3.5) lib/action_view/renderer/abstract_renderer.rb:87:in `instrument'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:57:in `block in render_template'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:65:in `render_with_layout'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:56:in `render_template'
actionview (6.0.3.5) lib/action_view/renderer/template_renderer.rb:13:in `render'
actionview (6.0.3.5) lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
actionview (6.0.3.5) lib/action_view/renderer/renderer.rb:29:in `render_to_object'
actionview (6.0.3.5) lib/action_view/rendering.rb:117:in `block in _render_template'
actionview (6.0.3.5) lib/action_view/base.rb:304:in `in_rendering_context'
actionview (6.0.3.5) lib/action_view/rendering.rb:116:in `_render_template'
actionpack (6.0.3.5) lib/action_controller/metal/streaming.rb:218:in `_render_template'
actionview (6.0.3.5) lib/action_view/rendering.rb:103:in `render_to_body'
actionpack (6.0.3.5) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (6.0.3.5) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (6.0.3.5) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (6.0.3.5) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (6.0.3.5) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/Users/renevanpelt/.rvm/rubies/ruby-2.5.1/lib/ruby/2.5.0/benchmark.rb:308:in `realtime'
activesupport (6.0.3.5) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (6.0.3.5) lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:43:in `render'
wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:46:in `call'
wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:46:in `render_with_wicked_pdf'
wicked_pdf (2.1.0) lib/wicked_pdf/pdf_helper.rb:30:in `render'
actionpack (6.0.3.5) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
actionpack (6.0.3.5) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
actionpack (6.0.3.5) lib/action_controller/metal/basic_implicit_render.rb:6:in `tap'
actionpack (6.0.3.5) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.3.5) lib/abstract_controller/base.rb:195:in `process_action'
actionpack (6.0.3.5) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.3.5) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:112:in `block in run_callbacks'
activesupport (6.0.3.5) lib/active_support/core_ext/time/zones.rb:66:in `use_zone'
app/controllers/dashboard_controller.rb:32:in `set_time_zone'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:121:in `block in run_callbacks'
activesupport (6.0.3.5) lib/active_support/callbacks.rb:139:in `run_callbacks'
actionpack (6.0.3.5) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.3.5) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.3.5) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.3.5) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.3.5) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.3.5) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.3.5) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.3.5) lib/abstract_controller/base.rb:136:in `process'
Update: I've generated a fresh rails 6 app and it works perfectly. The app that gives the error is just migrated from rails 5 to rails 6. Maybe that's where the difference between the two cases is.
Just run into the same issue today. Turns out I am using ruby 2.5 but then was introduced in ruby 2.6.
Upgrading ruby to 2.6.6 fixed the issue.

Rails: Unable to create a Global ID for Model without a model id

I am getting the following error from a Rails app:
URI::GID::MissingModelIdError in Treatment
Unable to create a Global ID for Treatment without a model id.
globalid (0.4.1) lib/global_id/uri/gid.rb:167:in `validate_model_id'
globalid (0.4.1) lib/global_id/uri/gid.rb:151:in `set_model_components'
globalid (0.4.1) lib/global_id/uri/gid.rb:136:in `check_path'
/Users/josh/.asdf/installs/ruby/2.5.1/lib/ruby/2.5.0/uri/generic.rb:819:in `path='
/Users/josh/.asdf/installs/ruby/2.5.1/lib/ruby/2.5.0/uri/generic.rb:193:in `initialize'
/Users/josh/.asdf/installs/ruby/2.5.1/lib/ruby/2.5.0/uri/generic.rb:138:in `new'
/Users/josh/.asdf/installs/ruby/2.5.1/lib/ruby/2.5.0/uri/generic.rb:138:in `build'
globalid (0.4.1) lib/global_id/uri/gid.rb:92:in `build'
globalid (0.4.1) lib/global_id/uri/gid.rb:68:in `create'
globalid (0.4.1) lib/global_id/global_id.rb:15:in `create'
globalid (0.4.1) lib/global_id/identification.rb:8:in `to_global_id'
activestorage (0.1) lib/active_storage/attached/one.rb:5:in `attachment'
activestorage (0.1) lib/active_storage/attached/one.rb:13:in `attached?'
app/views/treatments/_form.html.erb:52:in `block in _app_views_treatments__form_html_erb___357661333339907035_70285432864960'
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_helper.rb:450:in `form_for'
app/views/treatments/_form.html.erb:1:in `_app_views_treatments__form_html_erb___357661333339907035_70285432864960'
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/partial_renderer.rb:342:in `block in render_partial'
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/partial_renderer.rb:331:in `render_partial'
actionview (5.1.6) lib/action_view/renderer/partial_renderer.rb:310:in `render'
actionview (5.1.6) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionview (5.1.6) lib/action_view/helpers/rendering_helper.rb:35:in `render'
app/views/treatments/new.html.erb:42:in `_app_views_treatments_new_html_erb___2682657173693281074_70285432951520'
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/josh/.asdf/installs/ruby/2.5.1/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'
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'
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'
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.7) lib/warden/manager.rb:36:in `block in call'
warden (1.2.7) lib/warden/manager.rb:35:in `catch'
warden (1.2.7) lib/warden/manager.rb:35:in `call'
rack (2.0.5) lib/rack/etag.rb:25:in `call'
rack (2.0.5) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.5) lib/rack/head.rb:12:in `call'
rack (2.0.5) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.5) 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'
actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:59: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.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'
actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.5) lib/rack/method_override.rb:22:in `call'
rack (2.0.5) 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.5) 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'
I am getting this error when I try to load either the new or create method.
def new
#treatment = Treatment.new
end
def create
#treatment = Treatment.create!(treatment_params)
if #treatment.save
redirect_to root_path, notice: "Treatment added successfully"
else
render 'new', notice: "Oh no, Zuber u silly man!"
end
end
The error is generated by the Global ID gem
Seems to be a problem with the #treatment variable. When trying to use this in the view I get the error, but also when trying to save the data to the database.
The model looks like this (not sure why there are 6 separate images rather than many):
class Treatment < ApplicationRecord
extend FriendlyId
friendly_id :link, use: :slugged
validates :speciality,:link,:price,:duration,:image, presence: true
validates :content, presence: true, length: { minimum: 15}
has_one_attached :image
has_one_attached :image1
has_one_attached :image2
has_one_attached :image3
has_one_attached :image4
has_one_attached :image5
has_one_attached :image6
end
And the schema:
create_table "treatments", force: :cascade do |t|
t.string "category"
t.string "speciality"
t.text "content"
t.integer "price"
t.string "duration"
t.string "link"
t.string "image"
t.string "image1"
t.string "image2"
t.string "image3"
t.string "image4"
t.string "image5"
t.string "image6"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "slug"
t.index ["slug"], name: "index_treatments_on_slug", unique: true
end
I'm pretty new to Rails and am looking at this on behalf of a friend who is even newer, and I don't know what he may or may not have done previously to cause the error.
I hope someone can help, after a couple of hours of searching I couldn't find anything helpful.
Thanks!
EDIT:
I think this is something to do with Active Storage, as if I try to use #treatments.image.attached? in the view I get an error, but if just #treatments.image is used there is no error.
After realising that the app is in Rails 5.1.6, I decided to get rid of Active Storage in favour of the Paperclip gem. The error is no more!

Paperclip 5.1.0 - undefined method [] for nil after update

I am using paperclip to store images. After updating to 5.1.0 (released tonight) I get the following error:
undefined method `[]' for nil:NilClass
My code in the view is this:
<%= #company.pic1.url(:large)%>
A change in 5.1.0 is the switch to leave s3_protocol as an empty string, if not set in the app: Is it possible to configure Paperclip to produce HTTPS urls?
Following the advice there, I tried setting that string in the model to "http", "https" and :https, but didnt solve the problem.
What could be wrong? This is my model:
has_attached_file :pic1, :styles => { :large => "1000x600", :mid => "400x160", :thumb => "120x80>" }, :default_url => "https://s3.eu-central-1.amazonaws.com/server.assets/images/missing/image_missing_:style.png", :storage => :s3, :s3_credentials => APP_CONFIG["s3"], :path => ":class/:attachment/:style/:id.:extension", :s3_region => "eu-central-1", :s3_protocol => "http"
Thank you for any ideas how to solve this.
Full stacktrace here:
NoMethodError - undefined method `[]' for nil:NilClass:
delayed_paperclip (3.0.0) lib/delayed_paperclip/url_generator.rb:11:in `for' paperclip (5.1.0) lib/paperclip/attachment.rb:146:in `url'
app/views/public/_single_company_slide.html.erb:47:in `_app_views_public__single_company_slide_html_erb__1195386595_87856600'
actionview (4.2.5) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.5) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.5) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.5) lib/action_view/template.rb:143:in `render'
actionview (4.2.5) lib/action_view/renderer/partial_renderer.rb:339:in `render_partial'
actionview (4.2.5) lib/action_view/renderer/partial_renderer.rb:310:in `block in render'
actionview (4.2.5) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
activesupport (4.2.5) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.5) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.5) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
actionview (4.2.5) lib/action_view/renderer/partial_renderer.rb:309:in `render'
actionview (4.2.5) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionview (4.2.5) lib/action_view/renderer/renderer.rb:21:in `render'
actionview (4.2.5) lib/action_view/helpers/rendering_helper.rb:32:in `render'
app/views/public/_landing_slider.html.erb:18:in `block in _app_views_public__landing_slider_html_erb___1162164959_87953600'
activerecord (4.2.5) lib/active_record/relation/delegation.rb:132:in `method_missing'
activerecord (4.2.5) lib/active_record/relation/delegation.rb:99:in `method_missing'
app/views/public/_landing_slider.html.erb:17:in `_app_views_public__landing_slider_html_erb___1162164959_87953600'
actionview (4.2.5) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.5) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.5) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.5) lib/action_view/template.rb:143:in `render'
actionview (4.2.5) lib/action_view/renderer/partial_renderer.rb:339:in `render_partial'
actionview (4.2.5) lib/action_view/renderer/partial_renderer.rb:310:in `block in render'
actionview (4.2.5) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
activesupport (4.2.5) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.5) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.5) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
actionview (4.2.5) lib/action_view/renderer/partial_renderer.rb:309:in `render'
actionview (4.2.5) lib/action_view/renderer/renderer.rb:47:in `render_partial'
actionview (4.2.5) lib/action_view/renderer/renderer.rb:21:in `render'
actionview (4.2.5) lib/action_view/helpers/rendering_helper.rb:32:in `render'
app/views/public/home.html.erb:38:in `block in _app_views_public_home_html_erb___728996521_86764780'
actionview (4.2.5) lib/action_view/helpers/cache_helper.rb:190:in `write_fragment_for'
actionview (4.2.5) lib/action_view/helpers/cache_helper.rb:179:in `fragment_for'
actionview (4.2.5) lib/action_view/helpers/cache_helper.rb:115:in `cache'
app/views/public/home.html.erb:1:in `_app_views_public_home_html_erb___728996521_86764780'
actionview (4.2.5) lib/action_view/template.rb:145:in `block in render'
activesupport (4.2.5) lib/active_support/notifications.rb:166:in `instrument'
actionview (4.2.5) lib/action_view/template.rb:333:in `instrument'
actionview (4.2.5) lib/action_view/template.rb:143:in `render'
actionview (4.2.5) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (4.2.5) lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
activesupport (4.2.5) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.5) lib/active_support/notifications.rb:164:in `instrument'
actionview (4.2.5) lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
actionview (4.2.5) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (4.2.5) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (4.2.5) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (4.2.5) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (4.2.5) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (4.2.5) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (4.2.5) lib/action_view/rendering.rb:100:in `_render_template'
actionpack (4.2.5) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (4.2.5) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (4.2.5) lib/action_controller/metal/rendering.rb:32:in `render_to_body'
actionpack (4.2.5) lib/action_controller/metal/renderers.rb:37:in `render_to_body'
actionpack (4.2.5) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (4.2.5) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (4.2.5) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
C:/Ruby22-x64/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
activesupport (4.2.5) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (4.2.5) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.2.5) 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.2.5) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.2.5) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (4.2.5) lib/abstract_controller/base.rb:198:in `process_action'
actionpack (4.2.5) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.2.5) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.2.5) lib/active_support/callbacks.rb:117:in `call'
activesupport (4.2.5) lib/active_support/callbacks.rb:555:in `block (2 levels) in compile'
activesupport (4.2.5) lib/active_support/callbacks.rb:505:in `call'
activesupport (4.2.5) lib/active_support/callbacks.rb:92:in `__run_callbacks__'
activesupport (4.2.5) lib/active_support/callbacks.rb:778:in `_run_process_action_callbacks'
activesupport (4.2.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.5) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.2.5) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (4.2.5) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.5) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.5) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.5) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.5) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.5) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.5) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.5) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.5) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.2.5) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.5) lib/action_controller/metal.rb:237:in `block in action'
actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:76:in `dispatch'
actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:45:in `serve'
actionpack (4.2.5) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.5) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.5) lib/action_dispatch/routing/route_set.rb:817:in `call'
meta_request (0.4.0) lib/meta_request/middlewares/app_request_handler.rb:13:in `call'
meta_request (0.4.0) lib/meta_request/middlewares/meta_request_handler.rb:13:in `call'
rack-attack (5.0.1) lib/rack/attack.rb:147:in `call'
rack (1.6.4) lib/rack/deflater.rb:35:in `call'
warden (1.2.6) lib/warden/manager.rb:35:in `block in call'
warden (1.2.6) 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'
remotipart (1.2.1) lib/remotipart/middleware.rb:27:in `call'
actionpack (4.2.5) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.2.5) 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.5) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.2.5) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.2.5) lib/active_record/connection_adapters/abstract/connection_pool.rb:653:in `call'
activerecord (4.2.5) lib/active_record/migration.rb:377:in `call'
actionpack (4.2.5) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.2.5) lib/active_support/callbacks.rb:88:in `__run_callbacks__'
activesupport (4.2.5) lib/active_support/callbacks.rb:778:in `_run_call_callbacks'
activesupport (4.2.5) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (4.2.5) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.2.5) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.2.5) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
actionpack (4.2.5) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
rack-contrib (1.4.0) lib/rack/contrib/response_headers.rb:17:in `call'
meta_request (0.4.0) lib/meta_request/middlewares/headers.rb:16:in `call'
web-console (2.3.0) lib/web_console/middleware.rb:28:in `block in call'
web-console (2.3.0) lib/web_console/middleware.rb:18:in `call'
actionpack (4.2.5) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.2.5) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.2.5) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.2.5) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.2.5) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.2.5) lib/rails/rack/logger.rb:20:in `call'
quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
actionpack (4.2.5) 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.5) 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.5) lib/action_dispatch/middleware/static.rb:116:in `call'
rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
railties (4.2.5) lib/rails/engine.rb:518:in `call'
railties (4.2.5) lib/rails/application.rb:165:in `call'
rack (1.6.4) lib/rack/content_length.rb:15:in `call'
thin (1.7.0) lib/thin/connection.rb:86:in `block in pre_process'
thin (1.7.0) lib/thin/connection.rb:84:in `pre_process'
thin (1.7.0) lib/thin/connection.rb:53:in `process'
thin (1.7.0) lib/thin/connection.rb:39:in `receive_data'
eventmachine-1.2.0.1-x64 (mingw32) lib/eventmachine.rb:194:in `run'
thin (1.7.0) lib/thin/backends/base.rb:73:in `start'
thin (1.7.0) lib/thin/server.rb:162:in `start'
rack (1.6.4) lib/rack/handler/thin.rb:19:in `run'
rack (1.6.4) lib/rack/server.rb:286:in `start'
railties (4.2.5) lib/rails/commands/server.rb:80:in `start'
railties (4.2.5) lib/rails/commands/commands_tasks.rb:80:in `block in server'
railties (4.2.5) lib/rails/commands/commands_tasks.rb:75:in `server'
railties (4.2.5) lib/rails/commands/commands_tasks.rb:39:in `run_command!'
railties (4.2.5) lib/rails/commands.rb:17:in `<top (required)>'
bin/rails:4:in `<main>'
This is an old question and I'm posting here just in case anyone is maintaining a legacy project (and not switching to ActiveStorage). xfactorial solution did the trick for me. bundle update delayed_paperclip bumped the version up to 3.0.1.
My tests are passing now and the app is running ok.
Try updating your delayed_paperclip gem to 3.0.1

initialize method for an index action presenter

I want to make a presenter for an index action for Event.
here is what it looks like. there will be more methods and things added to the presenter and the view, but right now I just want to get this working:
class EventPresenter
def initialize(events, template)
#events = events
#template = template
end
def h
#template
end
def event_title
h.link_to event.name, event_path(event)
end
end
index.html.erb:
<% present #events do |event_presenter| %> <tr>
<td><%= event_presenter.event_title %></td>
<% end %>
application helper:
module ApplicationHelper
def present(object, klass = nil)
klass ||= "#{object.class}Presenter".constantize
presenter = klass.new(object, self)
yield presenter if block_given?
presenter
end
end
events_controller:
def index
#events = Event.all.map{ |event| EventPresenter.new(event) }
# render json: #events
end
the way it is now, I'm getting the wrong number of arguments (1 for 2) error for the presenter's initialize method. I was trying to see which of the two objects is not getting passed into the initializer by removing either #events or #template, such as:
def initialize(template)
#template = template
end
but, in both cases the app breaks at the klass ||= line of the application_helper with uninitialized constant ArrayPresenter, while it's supposed to be looking for the EventPresenter constant.
Full trace:
activesupport (5.0.0.beta3) lib/active_support/inflector/methods.rb:259:in `const_get'
activesupport (5.0.0.beta3) lib/active_support/inflector/methods.rb:259:in `block in constantize'
activesupport (5.0.0.beta3) lib/active_support/inflector/methods.rb:257:in `each'
activesupport (5.0.0.beta3) lib/active_support/inflector/methods.rb:257:in `inject'
activesupport (5.0.0.beta3) lib/active_support/inflector/methods.rb:257:in `constantize'
activesupport (5.0.0.beta3) lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
app/helpers/application_helper.rb:3:in `present'
app/views/events/index.html.erb:1:in `_app_views_events_index_html_erb__1682590753278671208_70298040094320'
actionview (5.0.0.beta3) lib/action_view/template.rb:158:in `block in render'
activesupport (5.0.0.beta3) lib/active_support/notifications.rb:166:in `instrument'
actionview (5.0.0.beta3) lib/action_view/template.rb:348:in `instrument'
actionview (5.0.0.beta3) lib/action_view/template.rb:156:in `render'
actionview (5.0.0.beta3) lib/action_view/renderer/template_renderer.rb:54:in `block (2 levels) in render_template'
actionview (5.0.0.beta3) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
activesupport (5.0.0.beta3) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.beta3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.beta3) lib/active_support/notifications.rb:164:in `instrument'
actionview (5.0.0.beta3) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
actionview (5.0.0.beta3) lib/action_view/renderer/template_renderer.rb:53:in `block in render_template'
actionview (5.0.0.beta3) lib/action_view/renderer/template_renderer.rb:61:in `render_with_layout'
actionview (5.0.0.beta3) lib/action_view/renderer/template_renderer.rb:52:in `render_template'
actionview (5.0.0.beta3) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (5.0.0.beta3) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (5.0.0.beta3) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (5.0.0.beta3) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.0.0.beta3) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (5.0.0.beta3) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (5.0.0.beta3) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.0.0.beta3) lib/action_controller/metal/renderers.rb:144:in `render_to_body'
actionpack (5.0.0.beta3) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (5.0.0.beta3) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:43:in `block (2 levels) in render'
activesupport (5.0.0.beta3) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/usr/local/Cellar/ruby/2.2.3/lib/ruby/2.2.0/benchmark.rb:303:in `realtime'
activesupport (5.0.0.beta3) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:43:in `block in render'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:86:in `cleanup_view_runtime'
activerecord (5.0.0.beta3) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:42:in `render'
actionpack (5.0.0.beta3) lib/action_controller/metal/implicit_render.rb:19:in `default_render'
actionpack (5.0.0.beta3) lib/action_controller/metal/basic_implicit_render.rb:4:in `block in send_action'
actionpack (5.0.0.beta3) lib/action_controller/metal/basic_implicit_render.rb:4:in `tap'
actionpack (5.0.0.beta3) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.0.0.beta3) lib/abstract_controller/base.rb:183:in `process_action'
actionpack (5.0.0.beta3) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.0.0.beta3) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:126:in `call'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:126:in `call'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:455:in `call'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:455:in `call'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:101:in `__run_callbacks__'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.beta3) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.0.0.beta3) lib/action_controller/metal/rescue.rb:27:in `process_action'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (5.0.0.beta3) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (5.0.0.beta3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.0.0.beta3) lib/active_support/notifications.rb:164:in `instrument'
actionpack (5.0.0.beta3) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (5.0.0.beta3) lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
activerecord (5.0.0.beta3) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (5.0.0.beta3) lib/abstract_controller/base.rb:128:in `process'
actionview (5.0.0.beta3) lib/action_view/rendering.rb:30:in `process'
actionpack (5.0.0.beta3) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (5.0.0.beta3) lib/action_controller/metal.rb:262:in `dispatch'
actionpack (5.0.0.beta3) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (5.0.0.beta3) lib/action_dispatch/routing/route_set.rb:32:in `serve'
actionpack (5.0.0.beta3) lib/action_dispatch/journey/router.rb:39:in `block in serve'
actionpack (5.0.0.beta3) lib/action_dispatch/journey/router.rb:26:in `each'
actionpack (5.0.0.beta3) lib/action_dispatch/journey/router.rb:26:in `serve'
actionpack (5.0.0.beta3) lib/action_dispatch/routing/route_set.rb:724:in `call'
actionview (5.0.0.beta3) lib/action_view/digestor.rb:12:in `call'
rack (2.0.0.alpha) lib/rack/etag.rb:25:in `call'
rack (2.0.0.alpha) lib/rack/conditional_get.rb:25:in `call'
rack (2.0.0.alpha) lib/rack/head.rb:12:in `call'
rack (2.0.0.alpha) lib/rack/session/abstract/id.rb:220:in `context'
rack (2.0.0.alpha) lib/rack/session/abstract/id.rb:214:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.0.0.beta3) lib/active_record/query_cache.rb:36:in `call'
activerecord (5.0.0.beta3) lib/active_record/connection_adapters/abstract/connection_pool.rb:963:in `call'
activerecord (5.0.0.beta3) lib/active_record/migration.rb:558:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.0.beta3) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/reloader.rb:71:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
web-console (3.1.1) lib/web_console/middleware.rb:131:in `call_app'
web-console (3.1.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.1.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.1.1) lib/web_console/middleware.rb:18:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.0.beta3) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.0.beta3) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.0.beta3) lib/active_support/tagged_logging.rb:70:in `block in tagged'
activesupport (5.0.0.beta3) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.0.beta3) lib/active_support/tagged_logging.rb:70:in `tagged'
railties (5.0.0.beta3) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/request_id.rb:24:in `call'
rack (2.0.0.alpha) lib/rack/method_override.rb:22:in `call'
rack (2.0.0.alpha) lib/rack/runtime.rb:22:in `call'
activesupport (5.0.0.beta3) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/load_interlock.rb:13:in `call'
actionpack (5.0.0.beta3) lib/action_dispatch/middleware/static.rb:136:in `call'
rack (2.0.0.alpha) lib/rack/sendfile.rb:111:in `call'
railties (5.0.0.beta3) lib/rails/engine.rb:522:in `call'
puma (3.4.0) lib/puma/configuration.rb:224:in `call'
puma (3.4.0) lib/puma/server.rb:569:in `handle_request'
puma (3.4.0) lib/puma/server.rb:406:in `process_client'
puma (3.4.0) lib/puma/server.rb:271:in `block in run'
puma (3.4.0) lib/puma/thread_pool.rb:114:in `call'
puma (3.4.0) lib/puma/thread_pool.rb:114:in `block in spawn_thread'
You seem to wrap event objects with a presenter by calling present method in a view layer, so doing the same thing in controller looks redundant to me. Moreover, that actually was a line resulting in wrong number of arguments, as you wrapped it with a single argument only. Let's remove it:
# events_controller
def index
#events = Event.all
# we removed redundant EventPresenter.new(event) here
end
Next step is your view template. As long as #events containts an array of elements (you could check the class of object parameter in your present helper method), you get "#{object.class}Presenter".constantize to end with "ArrayPresenter".constantize, and this results in an error as there is no such class as ArrayPresenter. What you could do here to solve this is to iterate an array first:
<% #events.each do |event| %>
<% present event do |event_presenter| %>
Another option could be to iterate a collection inside of your helper method. You might be intrested in some existing solutions like Draper gem to get an idea of how they solve the objects wrapping issues.

Resources