0

At Rails Console, I am trying to collect a distinct values of column.

For example : User model have a column name having status, in that column we store the status of that specific user.

Status are like ('NEW','PREMIUM','TEMP','BLOCKED','ON_HOLD' and etc)

At rails console, I am trying to get all this value in output. I am not getting the way to solve it.

Thanks in advance.

Rubyist
  • 6,486
  • 10
  • 51
  • 86

1 Answers1

0
User.uniq.pluck(:status)
# => ['NEW','PREMIUM','TEMP', ...]
Baldrick
  • 23,882
  • 6
  • 74
  • 79