Limiting max number of tags shown on debate cards ~ issue#144

This commit is contained in:
David Gil
2015-08-11 20:47:41 +02:00
parent e49567c953
commit 06d8c96d54
5 changed files with 25 additions and 6 deletions

View File

@@ -1,7 +1,15 @@
module ApplicationHelper
def tags(debate)
debate.tag_list.sort.map { |tag| link_to sanitize(tag), debates_path(tag: tag) }.join('').html_safe
def tags(debate, limit = nil)
tag_names = debate.tag_list_with_limit(limit)
tag_names.sort.map do |tag|
link_to sanitize(tag), debates_path(tag: tag)
end.join('').html_safe.tap do |output|
if limit && extra_tags = debate.tags_count_out_of_limit(limit)
output.concat(link_to("#{extra_tags}+", debate_path(debate)))
end
end
end
def percentage(vote, debate)