Created
May 28, 2016 16:46
-
-
Save aya-soft/3f5cb79961c330fb7524d0224dc6d424 to your computer and use it in GitHub Desktop.
Попахивающий кусок кода: на лицо дублирование и неправильное распределение обязанностей между объектами
This file contains 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
def spare_ratio_link(spare, url) | |
if SpareComment.has_comments?(spare) | |
link_to (rating_stars_row(average_ratio(spare)).html_safe + sum_ratios(spare).to_s), url | |
else | |
link_to (rating_stars_row(average_ratio(spare)).html_safe + sum_ratios(spare).to_s), '' | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Кстати у spare есть связь has_many :spare_comments, но можно еще одну добавить has_many :active_comments и условия прописать, чтобы выбирались только активные!