0
I’m trying to recover the months where I have answers to a survey 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 Warning from Rails:
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 to use 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__'
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__'
The way to use it is another?