If I’m using Devise with Rails, how do I go from:
User.all
to an array of email addresses that I can put into a select list?
Something like User.all.email?
Do I need to iterate over the list or is there a more elegant way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can do (only Ruby 1.9.2):
This is a simple form allowing you to call a single method on each object and return the results in an array.
You can also (both 1.8.7 and 1.9.2):
This allows for more complex manipulation, like:
Which of course returns a pair of id and a string containing name and email for each user.
Those methods actually have less to do with devise and more to do with Enumerable