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

Missing user ID when accessing audit log of certain projects #384

Open
dkhgh opened this issue Apr 7, 2016 · 3 comments
Open

Missing user ID when accessing audit log of certain projects #384

dkhgh opened this issue Apr 7, 2016 · 3 comments

Comments

@dkhgh
Copy link
Member

dkhgh commented Apr 7, 2016

On the audit log of certain projects I get a 500 error, caused by a missing user ID it seems.
This is not happening on all projects, not sure why.

Apr 07 02:55:12 hours-production app/web.1:  Completed 500 Internal Server Error in 22ms (ActiveRecord: 10.8ms) 
Apr 07 02:55:12 hours-production app/web.1:  ActionView::Template::Error (No route matches {:action=>"show", :controller=>"users", :id=>nil} missing required keys: [:id]): 
Apr 07 02:55:12 hours-production app/web.1:      1: = link_to user_path(user) do 
Apr 07 02:55:12 hours-production app/web.1:      2:   .avatar{ class: ("egg" if easter) , :style => "background-color: #{user.color};"} 
Apr 07 02:55:12 hours-production app/web.1:      3:     = user.acronyms 
Apr 07 02:55:12 hours-production app/web.1:      4:     = gravatar_image_tag(user.email, gravatar: { secure: true }, class: "image-circle", title: html_escape(user.full_name)) 
Apr 07 02:55:12 hours-production app/web.1:    app/views/application/_avatar.html.haml:1:in `_app_views_application__avatar_html_haml___2160406083279673600_70097682065800' 
Apr 07 02:55:12 hours-production app/web.1:    app/views/audits/_audits.html.haml:5:in `block in _app_views_audits__audits_html_haml__1577896411643312224_70097677361400' 
Apr 07 02:55:12 hours-production app/web.1:    app/views/audits/_audits.html.haml:2:in `each' 
Apr 07 02:55:12 hours-production app/web.1:    app/views/audits/_audits.html.haml:2:in `_app_views_audits__audits_html_haml__1577896411643312224_70097677361400' 
Apr 07 02:55:12 hours-production app/web.1:    app/views/audits/_project_audit.html.haml:22:in `_app_views_audits__project_audit_html_haml__916808747816020444_70097676694780' 
@jurre
Copy link
Contributor

jurre commented Apr 7, 2016

Perhaps an audit log of a deleted user? I don't think you can easily delete users, so it must have been a hard delete in the database

@nileshlg2003
Copy link

nileshlg2003 commented Aug 31, 2017

I am having the same problem. I have hosted it on Heroku. Whenever I go to /Users, app crashes this is the log from Heroku,

2017-08-31T17:21:16.363452+00:00 app[web.1]: ActionView::Template::Error (No route matches {:action=>"show", :controller=>"users", :id=>nil} missing required keys: [:id]): 2017-08-31T17:21:16.363453+00:00 app[web.1]: 7: - @users.each do |user| 2017-08-31T17:21:16.363454+00:00 app[web.1]: 8: %tr 2017-08-31T17:21:16.363455+00:00 app[web.1]: 9: %td 2017-08-31T17:21:16.363456+00:00 app[web.1]: 10: = link_to user.full_name, user_path(user) if user.confirmed? 2017-08-31T17:21:16.363456+00:00 app[web.1]: 11: %td= user.email 2017-08-31T17:21:16.363457+00:00 app[web.1]: 12: %td 2017-08-31T17:21:16.363458+00:00 app[web.1]: 13: - unless user.accepted_or_not_invited? 2017-08-31T17:21:16.363459+00:00 app[web.1]: app/views/users/index.html.haml:10:in block in _app_views_users_index_html_haml___659651559752492815_70194425770680'
2017-08-31T17:21:16.363460+00:00 app[web.1]: app/views/users/index.html.haml:7:in _app_views_users_index_html_haml___659651559752492815_70194425770680' 2017-08-31T17:21:16.363461+00:00 app[web.1]: 2017-08-31T17:21:16.363461+00:00 app[web.1]:

Now I wonder, How do I fix it without losing my Data?

@tarzan
Copy link
Member

tarzan commented Sep 1, 2017

The error you see, does not seem related. Your app crashes because the template tries to iterate over users without an id. From the code, I can't figure out which user(s) that could be: the controller assigns User.all to @users, which the template iterates over and constructs links for each user using its id.
So, the question is: What does your database's Users table contain? Have you changed the primary key of the users table? What database do you use and is it fully migrated?

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

4 participants