Defect #18332
closed
Error when displaying a news with comments in reverse order
Added by Denis Savitskiy about 10 years ago.
Updated about 10 years ago.
Description
Extra bang after
@comments.reverse
in news_controller.rb causes 500 error if no comments are present while
User.current.wants_comments_in_reverse_order? == true
- Target version set to 2.6.1
- Status changed from New to Needs feedback
- Target version deleted (
2.6.1)
- Subject changed from Extra bang after @comments.reverse in news_controller causes 500 error to Error when displaying a news with comments in reverse order
- Status changed from Needs feedback to Resolved
- Assignee set to Jean-Philippe Lang
- Target version set to 2.6.1
- Resolution set to Fixed
Fixed in r13595.
The problem was not with the bang nor the fact that there are no comments. It would have been easier to get it with your stack trace but thanks anyway for reporting this.
What is the purpose of this bang? You are not storing the order. You simply change the order in array before showing it to user.
#reverse
returns a reversed array but leaves the array unchanged, so we'd have to use @comments = @comments.reverse
instead of @comments.reverse!
- Status changed from Resolved to Closed
- Target version deleted (
2.6.1)
- Affected version deleted (
2.6.0)
2.6 stable is not affected, trunk only.
Jean-Philippe Lang wrote:
Fixed in r13595.
Thanks!
#reverse
returns a reversed array but leaves the array unchanged, so we'd have to use @comments = @comments.reverse
instead of @comments.reverse!
Sure! I didn't mention that.
Also available in: Atom
PDF