Describe the bug
After the #15002 there seems to be a bug when the notification is an attachment.
Since now the cell checks if the user can participate in that resource, that asks the attachment model for a method that does not exist.
def show
if !notification.can_participate?(current_user)
render :not_available
elsif notification.deleted_resource?
render :deleted
elsif notification.hidden_resource?
render :moderated
else
render :show
end
end
This has caused problems with other models, such as in this pr #15830
To Reproduce
- Upload an attachment to a process with one admin user
- Go to the notifications of a second admin user
- See it crash
Expected behavior
You can access the notification landing and see the notifications of type Decidim::Attachment
Screenshots
No response
Stacktrace
Cause: NoMethodError: undefined method can_participate?' for an instance of Decidim::Attachment /usr/local/bundle/gems/activemodel-7.2.3/lib/active_model/attribute_methods.rb:512:in method_missing'
/usr/local/bundle/gems/activerecord-7.2.3/lib/active_record/attribute_methods.rb:495:in method_missing' /usr/local/bundle/bundler/gems/decidim-e3f6fc3ac643/decidim-core/app/models/decidim/notification.rb:41:in can_participate?'
/usr/local/lib/ruby/3.3.0/delegate.rb:87:in method_missing' /usr/local/bundle/bundler/gems/decidim-e3f6fc3ac643/decidim-core/app/cells/decidim/notification_cell.rb:10:in show'
Extra data
- Decidim Version: 0.31 (release branch)
- Decidim installation: Participa Navarra
Additional context
No response
Describe the bug
After the #15002 there seems to be a bug when the notification is an attachment.
Since now the cell checks if the user can participate in that resource, that asks the attachment model for a method that does not exist.
This has caused problems with other models, such as in this pr #15830
To Reproduce
Expected behavior
You can access the notification landing and see the notifications of type
Decidim::AttachmentScreenshots
No response
Stacktrace
Cause: NoMethodError: undefined method
can_participate?' for an instance of Decidim::Attachment /usr/local/bundle/gems/activemodel-7.2.3/lib/active_model/attribute_methods.rb:512:inmethod_missing'/usr/local/bundle/gems/activerecord-7.2.3/lib/active_record/attribute_methods.rb:495:in
method_missing' /usr/local/bundle/bundler/gems/decidim-e3f6fc3ac643/decidim-core/app/models/decidim/notification.rb:41:incan_participate?'/usr/local/lib/ruby/3.3.0/delegate.rb:87:in
method_missing' /usr/local/bundle/bundler/gems/decidim-e3f6fc3ac643/decidim-core/app/cells/decidim/notification_cell.rb:10:inshow'Extra data
Additional context
No response