I have two models, user & offline_user, and
I want to use a dropdown select control such as a collection_select to choose an item from a combined list of the contents of both models.
How would I do this?
They are quite similar, they both contain a first_name, last_name, email address and telephone field. However an email address is mandatory for the user model while it is not mandatory for the offline user model. I use devise for the user model authentication.
The reasoning behind this is as follows,
I use email address as the web application login but I also need to cater for customers who telephone the business and perhaps do not have an email address. So I want the admin to be able to create new users without requiring an email address.
The business will also have a list of existing customers who will not have been asked to provide an email address. I want to be able to import this list.
Perhaps I should be using just one model, but at the time it seemed best to keep them separate. Suggestions?
If you were to use the migration
and then the model
This will allow you to have both types of users in one model, as well as ensuring that a normal user does have an e-mail address.
You could then use the normal
User.all.select(:first_name)facilities to grab all the user names