Oom Tuinstoel
2006-Mar-14 19:17 UTC
[Rails] 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? -- Posted via http://www.ruby-forum.com/.
Mark Reginald James
2006-Mar-15 14:51 UTC
[Rails] Re: Nubie: collection_select with two fields concatenated
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.