I'm trying to retrieve the months I have answers to a search this way:
Answers.pluck('EXTRACT(MONTH FROM created_at)').uniq
(0.7ms) SELECT EXTRACT(MONTH FROM created_at) FROM 'answers'
=> [3]
This way I have the expected result, but I get a rails warning:
DEPRECATION WARNING: uniq is deprecated and will be removed from Rails 5.1
(use distinct instead) (called from __pry__ at (pry):8)
When I try to follow the suggestion of using distinct without parameters:
Answers.pluck('EXTRACT(MONTH FROM created_at)').distinct()
(0.4ms) SELECT EXTRACT(MONTH FROM created_at) FROM 'answers'
NoMethodError: undefined method 'distinct' for [3, 3]:Array
from (pry):33:in '__pry__'
with parameter:
Answers.pluck('EXTRACT(MONTH FROM created_at)').distinct('EXTRACT(MONTH FROM created_at)')
(0.4ms) SELECT EXTRACT(MONTH FROM created_at) FROM 'answers'
NoMethodError: undefined method 'distinct' for [3, 3]:Array
from (pry):33:in '__pry__'
Answers.pluck('EXTRACT(MONTH FROM created_at)').distinct(:created_at)
(0.7ms) SELECT EXTRACT(MONTH FROM created_at) FROM 'answers'
NoMethodError: undefined method 'distinct' for [3, 3]:Array
from (pry):35:in '__pry__'
Is there another way to use it?