How to add a condition in a Select form tag?

Hi,

i ve got this piece of code :
<%= select(“profile”, “vlogiciel”, @vlogiciel.collect {|vlogiciel|
[ vlogiciel.logiciel.nom,
vlogiciel.id ] }, :include_blank=>true, :selected=>(@vl).to_i )%>

But i would like to do that

<%= select(“profile”, “vlogiciel”, @vlogiciel.collect {|vlogiciel|
[ vlogiciel.logiciel.nom + vlogiciel.lversion.nom,
vlogiciel.id ] }, :include_blank=>true, :selected=>(@vl).to_i )%>

But sometime vlogiciel.lversion is NULL,
so i need to add an unless condition like that :

<%= select(“profile”, “vlogiciel”, @vlogiciel.collect {|vlogiciel|
[ vlogiciel.logiciel.nom +
unless vlogiciel.lversion == nil
vlogiciel.lversion.nom
end, vlogiciel.id ] }, :include_blank=>true, :selected=>(@vl).to_i )%>

There is synthax error so it s not working.
i can t figure out how to add a conditions into this select…

Does anyone have an idea ?

Thanks
Guillaume.

Assemble your collection for the select in the controller where you have
free reign on how the data is brought together and/or massaged for
display?

Or use an immediate if (or whatever Ruby calls it)

[vlogiciel.logicial.nom+(vlogicial.lversion.nil? ? ‘’ :
vlogicial.lversion), vlogiciel.id]

Haven’t tried it myself, but that is left as “an exercise for the
reader…”

You are my star :slight_smile:

Thanks so much !!!