Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ActionView::Template::Error: undefined method `name' for nil:NilClass #838

Open
aaronskiba opened this issue Aug 1, 2024 · 3 comments
Open
Assignees

Comments

@aaronskiba
Copy link
Collaborator

View details in Rollbar: https://app.rollbar.com/a/ualbertalib/fix/item/dmp_assistant/507


NoMethodError: undefined method `name' for nil:NilClass
  File "/var/www/sites/dmp/app/views/plans/_share_form.html.erb", line 60, in block in _app_views_plans__share_form_html_erb__572304556254234312_322960
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activerecord-6.1.7.8/lib/active_record/relation/delegation.rb", line 88, in each
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activerecord-6.1.7.8/lib/active_record/relation/delegation.rb", line 88, in each
  File "/var/www/sites/dmp/app/views/plans/_share_form.html.erb", line 58, in _app_views_plans__share_form_html_erb__572304556254234312_322960
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/base.rb", line 247, in public_send
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/base.rb", line 247, in _run
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/template.rb", line 154, in block in render
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb", line 205, in instrument
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/template.rb", line 345, in instrument_render_template
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/template.rb", line 152, in render
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/partial_renderer.rb", line 285, in block in render_partial_template
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb", line 203, in block in instrument
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activesupport-6.1.7.8/lib/active_support/notifications/instrumenter.rb", line 24, in instrument
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb", line 203, in instrument
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/partial_renderer.rb", line 280, in render_partial_template
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/partial_renderer.rb", line 271, in render
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/renderer.rb", line 81, in render_partial_to_object
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/renderer.rb", line 27, in render_to_object
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/renderer.rb", line 22, in render
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/helpers/rendering_helper.rb", line 38, in block in render
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/base.rb", line 273, in in_rendering_context
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/helpers/rendering_helper.rb", line 34, in render
  File "/var/www/sites/dmp/app/views/plans/share.html.erb", line 11, in _app_views_plans_share_html_erb___3665773786412046771_322940
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/base.rb", line 247, in public_send
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/base.rb", line 247, in _run
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/template.rb", line 154, in block in render
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb", line 205, in instrument
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/template.rb", line 345, in instrument_render_template
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/template.rb", line 152, in render
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/template_renderer.rb", line 61, in block (2 levels) in render_template
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb", line 203, in block in instrument
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activesupport-6.1.7.8/lib/active_support/notifications/instrumenter.rb", line 24, in instrument
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb", line 203, in instrument
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/template_renderer.rb", line 56, in block in render_template
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/template_renderer.rb", line 71, in block in render_with_layout
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb", line 203, in block in instrument
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activesupport-6.1.7.8/lib/active_support/notifications/instrumenter.rb", line 24, in instrument
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/activesupport-6.1.7.8/lib/active_support/notifications.rb", line 203, in instrument
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/template_renderer.rb", line 70, in render_with_layout
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/template_renderer.rb", line 55, in render_template
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/template_renderer.rb", line 11, in render
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/renderer.rb", line 61, in render_template_to_object
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/renderer/renderer.rb", line 29, in render_to_object
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/rendering.rb", line 117, in block in _render_template
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/base.rb", line 273, in in_rendering_context
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/rendering.rb", line 116, in _render_template
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionpack-6.1.7.8/lib/action_controller/metal/streaming.rb", line 218, in _render_template
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionview-6.1.7.8/lib/action_view/rendering.rb", line 103, in render_to_body
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/actionpack-6.1.7.8/lib/action_controller/metal/rendering.rb", line 52, in render_to_body
  File "/var/www/sites/dmp/vendor/ruby/3.1.0/gems/acti
@aaronskiba
Copy link
Collaborator Author

Further details from rollbar.com reveal that this error occurs on the path /plans/10811/share.

3.1.4 :001 > Role.where(plan_id: 10833)
  Role Load (1.9ms)  SELECT "roles".* FROM "roles" WHERE "roles"."plan_id" = $1  [["plan_id", 10833]]
 =>                                                         
[#<Role:0x000079f77a3561f0                                  
  id: 13363,                                                
  user_id: 22885,                                           
  plan_id: 10833,                                           
  created_at: Mon, 13 Mar 2023 14:44:15.559673000 UTC +00:00,
  updated_at: Mon, 13 Mar 2023 14:44:15.559673000 UTC +00:00,
  access: 15,                                               
  active: true>,                                            
 #<Role:0x000079f77a3433c0                                  
  id: 13383,                                                
  user_id: 22690,                                           
  plan_id: 10833,                                           
  created_at: Tue, 14 Mar 2023 13:52:40.282986000 UTC +00:00,
  updated_at: Tue, 14 Mar 2023 13:52:40.282986000 UTC +00:00,
  access: 14,
  active: true>,
 #<Role:0x000079f77a343230
  id: 13386,
  user_id: 22685,
  plan_id: 10833,
  created_at: Tue, 14 Mar 2023 13:53:24.238440000 UTC +00:00,
  updated_at: Tue, 14 Mar 2023 13:53:24.238440000 UTC +00:00,
  access: 14,
  active: true>,
 #<Role:0x000079f77a3430a0
  id: 13387,
  user_id: 22696,
  plan_id: 10833,
  created_at: Tue, 14 Mar 2023 13:53:53.547210000 UTC +00:00,
  updated_at: Tue, 14 Mar 2023 13:53:53.547210000 UTC +00:00,
  access: 14,
  active: true>,
 #<Role:0x000079f77a342fb0
  id: 13392,
  user_id: nil,
  plan_id: 10833,
  created_at: Tue, 14 Mar 2023 17:16:42.966686000 UTC +00:00,
  updated_at: Tue, 14 Mar 2023 17:16:42.966686000 UTC +00:00,
  access: 14,
  active: true>]

The last Role entry has user_id = nil.

3.1.4 :002 > Role.find(13392).user.name
  Role Load (1.4ms)  SELECT "roles".* FROM "roles" WHERE "roles"."id" = $1 LIMIT $2  [["id", 13392], ["LIMIT", 1]]
(irb):2:in `<main>': undefined method `name' for nil:NilClass (NoMethodError)                
3.1.4 :003 > Role.find(13392).user
  Role Load (2.9ms)  SELECT "roles".* FROM "roles" WHERE "roles"."id" = $1 LIMIT $2  [["id", 13392], ["LIMIT", 1]]
 => nil

@aaronskiba
Copy link
Collaborator Author

The db has only two roles entries with user_id == nil:

3.1.4 :001 > Role.where(user_id: nil)
  Role Load (2.0ms)  SELECT "roles".* FROM "roles" WHERE "roles"."user_id" IS NULL
 =>                                                                        
[#<Role:0x000079f77ad7f5c8                                                 
  id: 13391,                                                               
  user_id: nil,                                                            
  plan_id: 10811,                                                          
  created_at: Tue, 14 Mar 2023 17:16:42.960364000 UTC +00:00,              
  updated_at: Tue, 14 Mar 2023 17:16:42.960364000 UTC +00:00,              
  access: 14,                                                              
  active: true>,                                                           
 #<Role:0x000079f77ada2ff0                                                 
  id: 13392,                                                               
  user_id: nil,                                                            
  plan_id: 10833,                                                          
  created_at: Tue, 14 Mar 2023 17:16:42.966686000 UTC +00:00,              
  updated_at: Tue, 14 Mar 2023 17:16:42.966686000 UTC +00:00,
  access: 14,
  active: true>] 

@lagoan
Copy link
Collaborator

lagoan commented Aug 19, 2024

@aaronskiba will take a look at the database and find reason for nil user_id

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

No branches or pull requests

2 participants