"Questions by an author" page showing an error
When on this page: https://publiclab.org/tag/ndvi/author/warren
you can click on "Questions" leading to:
https://publiclab.org/questions/tag/ndvi/author/warren
But that page shows an error! I'm not sure if it's a routing issue or that we don't have author-specific controller code?
@Souravirus any idea if this is routing? Thanks!
I would like to take this bug. I am not able to get the required data though. Thanking you in advance !
I think here, we should be displaying this action: https://github.com/publiclab/plots2/blob/master/app/controllers/tag_controller.rb#L168
Can you try going to this page on your local copy to see what the error is and copying in the error here?
https://publiclab.org/questions/tag/test/author/admin
A few other combinations of username and tag name (admin and test) might help narrow in on the error.
Helo @jywarren I would like to work on this. But I am having trouble replicating the bug locally http://localhost:3000/questions/tag/test/author/admin works okay though no results are displayed. Any other suggestions on how I can replicate this bug? Thanks.
OK! I pulled the logs for this, and found:
[c67ca413-751b-4635-aeb5-cc0ed6d69798] Completed 500 Internal Server Error in 5458ms (ActiveRecord: 3587.3ms)
[c67ca413-751b-4635-aeb5-cc0ed6d69798]
[c67ca413-751b-4635-aeb5-cc0ed6d69798] ActionView::Template::Error (undefined method `answers' for nil:NilClass):
[c67ca413-751b-4635-aeb5-cc0ed6d69798] 1: <div id="answered-question">
[c67ca413-751b-4635-aeb5-cc0ed6d69798] 2: <div class="row">
[c67ca413-751b-4635-aeb5-cc0ed6d69798] 3: <% @answered_questions.each_with_index do |question,i| %>
[c67ca413-751b-4635-aeb5-cc0ed6d69798] 4: <% answers = if @user then question.answers.where(uid: @user.uid) else question.answers end %>
[c67ca413-751b-4635-aeb5-cc0ed6d69798] 5: <div class="col-md-4" style="margin-top:30px;">
[c67ca413-751b-4635-aeb5-cc0ed6d69798] 6: <div class="note note-pane note-answer">
[c67ca413-751b-4635-aeb5-cc0ed6d69798] 7: <div class="header-icon"><i class="fa fa-question-circle"></i></div>
[c67ca413-751b-4635-aeb5-cc0ed6d69798]
[c67ca413-751b-4635-aeb5-cc0ed6d69798] app/views/users/_answered.html.erb:4:in `block in _app_views_users__answered_html_erb___353372676395592086_47453034473680'
[c67ca413-751b-4635-aeb5-cc0ed6d69798] app/views/users/_answered.html.erb:3:in `each'
[c67ca413-751b-4635-aeb5-cc0ed6d69798] app/views/users/_answered.html.erb:3:in `each_with_index'
[c67ca413-751b-4635-aeb5-cc0ed6d69798] app/views/users/_answered.html.erb:3:in `_app_views_users__answered_html_erb___353372676395592086_47453034473680'
[c67ca413-751b-4635-aeb5-cc0ed6d69798] app/views/tag/show/_tab_content.html.erb:33:in `_app_views_tag_show__tab_content_html_erb__1314859714535106663_69835367556480'
[c67ca413-751b-4635-aeb5-cc0ed6d69798] app/views/tag/show.html.erb:25:in `_app_views_tag_show_html_erb__4321502815545471151_69835372305880'
[c67ca413-751b-4635-aeb5-cc0ed6d69798] app/controllers/tag_controller.rb:219:in `block (2 levels) in show_for_author'
[c67ca413-751b-4635-aeb5-cc0ed6d69798] app/controllers/tag_controller.rb:218:in `show_for_author'
So maybe somehow we are not getting @answered_questions from this line:
https://github.com/publiclab/plots2/blob/cc2df02a63b72cca7b1129aa3044933abf614a50/app/controllers/tag_controller.rb#L207
potentially something is going on with each_with_index?
I'm going to leave this open for now to see if @cesswairimu 's fix worked. I think we should be able to try it out here in a few minutes:
https://stable.publiclab.org/questions/tag/ndvi/author/warren
@cesswairimu could you give it a try? In perhaps 10 minutes.