comfy / comfortable-mexican-sofa

ComfortableMexicanSofa is a powerful Ruby on Rails 5.2+ CMS (Content Management System) Engine
MIT License
2.72k stars 637 forks source link

undefined method `service_name' for #<ActiveStorage::Blob:0x00007fa1d3eec970> #924

Closed rgaufman closed 3 years ago

rgaufman commented 3 years ago

Expected behavior

Blog should load

Actual behavior

The blog throws a 500 internal server error when viewing. The admin section works however:

I, [2021-01-28T19:28:06.933249 #22573]  INFO -- : [eaac4e11-e953-46a6-ac1f-63101b80e9ce]   Rendered layout /usr/local/lib/ruby/gems/2.7.0/gems/comfortable_mexican_sofa-2.0.19/app/views/layouts/comfy/admin/cms.html.haml (Duration: 35.2ms | Allocations: 12760)
I, [2021-01-28T19:28:06.933442 #22573]  INFO -- : [eaac4e11-e953-46a6-ac1f-63101b80e9ce] Completed 500 Internal Server Error in 39ms (ActiveRecord: 1.7ms | Allocations: 13993)
F, [2021-01-28T19:28:06.934424 #22573] FATAL -- : [eaac4e11-e953-46a6-ac1f-63101b80e9ce]
[eaac4e11-e953-46a6-ac1f-63101b80e9ce] ActionView::Template::Error (undefined method `service_name' for #<ActiveStorage::Blob:0x00007fa1d3eec970>
Did you mean?  service):
[eaac4e11-e953-46a6-ac1f-63101b80e9ce]     1: .fragment-attachments
[eaac4e11-e953-46a6-ac1f-63101b80e9ce]     2:   - attachments.each do |attachment|
[eaac4e11-e953-46a6-ac1f-63101b80e9ce]     3:     :ruby
[eaac4e11-e953-46a6-ac1f-63101b80e9ce]     4:       thumb_url = if attachment.variable?
[eaac4e11-e953-46a6-ac1f-63101b80e9ce]     5:         url_for(attachment.variant(combine_options: Comfy::Cms::File::VARIANT_SIZE[:thumb]))
[eaac4e11-e953-46a6-ac1f-63101b80e9ce]     6:       end
[eaac4e11-e953-46a6-ac1f-63101b80e9ce]
[eaac4e11-e953-46a6-ac1f-63101b80e9ce] app/lib/page_validation.rb:21:in `fragment_field'
I, [2021-01-28T19:28:06.934986 #22573]  INFO -- : [eaac4e11-e953-46a6-ac1f-63101b80e9ce] Processing by ErrorsController#internal_server_error as HTML
I, [2021-01-28T19:28:06.935032 #22573]  INFO -- : [eaac4e11-e953-46a6-ac1f-63101b80e9ce]   Parameters: {"site_id"=>"1", "id"=>"2"}
D, [2021-01-28T19:28:06.935523 #22573] DEBUG -- : [eaac4e11-e953-46a6-ac1f-63101b80e9ce]   Rendering layout layouts/application.html.slim
D, [2021-01-28T19:28:06.935592 #22573] DEBUG -- : [eaac4e11-e953-46a6-ac1f-63101b80e9ce]   Rendering errors/internal_server_error.html.slim within layouts/application
I, [2021-01-28T19:28:06.935758 #22573]  INFO -- : [eaac4e11-e953-46a6-ac1f-63101b80e9ce]   Rendered errors/internal_server_error.html.slim within layouts/application (Duration: 0.1ms | Allocations: 27)
I, [2021-01-28T19:28:06.936785 #22573]  INFO -- : [eaac4e11-e953-46a6-ac1f-63101b80e9ce]   Rendered layout layouts/application.html.slim (Duration: 1.2ms | Allocations: 731)
I, [2021-01-28T19:28:06.937399 #22573]  INFO -- : [eaac4e11-e953-46a6-ac1f-63101b80e9ce] Completed 500 Internal Server Error in 2ms (Views: 1.7ms | ActiveRecord: 0.0ms | Allocations: 1173)
I, [2021-01-28T19:28:08.571881 #22573]  INFO -- : [ab5a242a-9331-4efb-b5cd-c598cda0263b] Started HEAD "/" for 63.143.42.249 at 2021-01-28 19:28:08 +0000
I, [2021-01-28T19:28:08.572526 #22573]  INFO -- : [ab5a242a-9331-4efb-b5cd-c598cda0263b] Processing by PagesController#home as HTML
D, [2021-01-28T19:28:08.573169 #22573] DEBUG -- : [ab5a242a-9331-4efb-b5cd-c598cda0263b]   Rendering layout layouts/application.html.slim
D, [2021-01-28T19:28:08.573232 #22573] DEBUG -- : [ab5a242a-9331-4efb-b5cd-c598cda0263b]   Rendering pages/home.html.slim within layouts/application
I, [2021-01-28T19:28:08.574208 #22573]  INFO -- : [ab5a242a-9331-4efb-b5cd-c598cda0263b]   Rendered pages/home.html.slim within layouts/application (Duration: 0.9ms | Allocations: 913)
I, [2021-01-28T19:28:08.576365 #22573]  INFO -- : [ab5a242a-9331-4efb-b5cd-c598cda0263b]   Rendered layout layouts/application.html.slim (Duration: 3.1ms | Allocations: 1613)
I, [2021-01-28T19:28:08.577155 #22573]  INFO -- : [ab5a242a-9331-4efb-b5cd-c598cda0263b] Completed 200 OK in 5ms (Views: 3.6ms | ActiveRecord: 0.0ms | Allocations: 2125)

Steps to reproduce

This happened after doing a bundle update

System configuration

Rails version: rails (6.1.1) CMS version: comfortable_mexican_sofa (2.0.19) Ruby version: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux]

rgaufman commented 3 years ago

I found this: https://stackoverflow.com/questions/65499645/undefined-method-service-name-for-activestorageblob-after-upgrading-to-rails

I tried to run:

rails active_storage:update

But after restarting rails, still getting a 500 server error and this in the log:

[714c03bd-f81c-475b-9a82-c574573d7c2a] ActionView::Template::Error (undefined method `service_name' for #<ActiveStorage::Blob:0x00007fa4258295a8>
rgaufman commented 3 years ago

Ah, had to run:

rake db:migrate 

After updating active_storage. Now working again!