in case someone had this issue - in the end I have Tomaž Zaman solution with the helper method modification as below:
ruby
deftag_cloud(tags, classes)
max = 0
tags.each do |t|
if t.count.to_i > max
max = t.count.to_i
endend
tags.each do |tag|
index = tag.count.to_f / max * (classes.size - 1)
yield(tag, classes[index.round])
endend
I used this code, and it works but only if there are few tags.
Problem is that count is not a number so
max = tags.sort_by(&:count).last
doesn't sort it properly when number of tags is more than 9 for specific post/article.
I will try to write function to find max properly unless anyone has an idea how to have it as a number in the first place..
it is not working for me as well..
I get the error:
PGError: ERROR: column "tags.id" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT tags.*, count(taggings.tag_id) as count FROM "tags" I...
in case someone had this issue - in the end I have Tomaž Zaman solution with the helper method modification as below:
I used this code, and it works but only if there are few tags.
Problem is that count is not a number so
max = tags.sort_by(&:count).last
doesn't sort it properly when number of tags is more than 9 for specific post/article.
I will try to write function to find max properly unless anyone has an idea how to have it as a number in the first place..
worked like a charm :) Thank you!!
it is not working for me as well..
I get the error:
Can anyone help with that?
ah I was looking for this for half a day! :) Thank you!!
Adrian - thank you! this is exactly what I needed (I have a bit different routes).
and for me (starting with rails) verbose is an awesome feature :)
Thank you for answering yourself as this is just what I was looking for :)