Conversation
| li { data-id = a.id } | ||
| = link_to a.file.filename, a.file.url | ||
| = ' ' | ||
| - if current_user && current_user.author_of?(answer) |
There was a problem hiding this comment.
Учти, что здесь закешируются ссылки и после перелогина они не изменятся. Например, если в первый раз на страницу зайдет гость или не-автор, ссылок не будет и закешируется такая страница. И даже если после этого автор зайдет на страницу, он ссылок не увидит, т.к. логика в кеше не работает, там уже отрендеренный html.
Вариантов несколько:
- Добавлять/скрывать ссылки через js
- Кешировать все, кроме условий. Но тут есть проблема в том, что будет очень много мелких фрагментов кеша и не факт, что это даст хороший прирост скорости
- В ключ кеширования добавить флаг залогиненн пользователь или нет (можно еще и по автору). Но тут важно добавлять именно true/false, а не id юзера, т.к. в этом случае для каждого юзера будет отдельный кеш и смысл кеширования потеряется вообще.
|
Принято, но учти замечания |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.