Nubie: collection_select with two fields concatenated

I have a table with (among others) :prefix and :lastname

In my view in a collection_select I want to see “prefix lastname”. I
have ab-so-lu-te-ly no idea how to do this. Can anybody show me?

Oom Tuinstoel wrote:

I have a table with (among others) :prefix and :lastname

In my view in a collection_select I want to see “prefix lastname”. I
have ab-so-lu-te-ly no idea how to do this. Can anybody show me?

Add a method to your model that returns “#{prefix} #{lastname}”,
and use this as your text method in collection_select.


We develop, watch us RoR, in numbers too big to ignore.

Thanks, Mark

I guess I’m still not used to the simplicity of rails…