0

I am using gem 'chartkick' and have such code:

        <%= pie_chart question.responses.group(:answer_variant_id).count %>

the table responses is connected with table answer_variants through answer_variant_id. Currently my pie chart shows answer variant ids, but how could I make it displaying answer_variant.title?

Thanks

Neon_10
  • 711
  • 2
  • 7
  • 19

1 Answers1

0

I resolved this. Needed to join another table. The answer looks like this:

<%= pie_chart question.responses.joins(:answer_variant).group(:title).count %>
Neon_10
  • 711
  • 2
  • 7
  • 19