Rails 2.3.5
I’m not having any luck searching for an answer on this. I know I could just write out a manual sql statement with a concat in it, but I thought I’d ask:
To load a select, I’m running a query of shift records. I’m trying to make the value in the select be shift date followed by a space and then the shift name. I can’t figure out the syntax for doing a concat of two fields in a collect. The Ruby docs make it looks like plus signs and double quotes should work in a collect but everything I try gets a “expected numeric” error from Rails.
@shift_list = [a find query].collect{|s| [s.shift_date + " " + s.shift_name, s.id]}
Thanks for any help – much appreciated.
Hard to say without knowing what
sis going to be or what types.shift_dateands.shift_nameare but maybe you’re looking for this:That is pretty much the same as:
but less noisy.