# Extra field being added to db with multiple select?

**URL:** <https://www.ruby-forum.com/t/extra-field-being-added-to-db-with-multiple-select/90473>\
**Category:** Rails\
**Created:** [March 29, 2007, 2:22am UTC](https://www.ruby-forum.com/t/extra-field-being-added-to-db-with-multiple-select/90473 "2007-03-29T02:22:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![garrido](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a8b319/32.png) [@garrido](https://www.ruby-forum.com/u/garrido)\
**Post date:** [March 29, 2007, 2:22am UTC](https://www.ruby-forum.com/t/extra-field-being-added-to-db-with-multiple-select/90473/1 "2007-03-29T02:22:54Z")

</div>

Hi all,

First of all, please bear in mind my absolute noobness to Rails and in  
fact to programming in general. I have a question regarding a  
multiple select box. I’ve managed to get it working with the  
following code in my \_form view:

Tech  
\<%= select\_tag('vacancy[tech][]', options\_for\_select(['css', 'php', 'Java']), {:multiple =\> true}) %\>

The problem is, when multiple values are selected, extra dashes get  
added to the DB. A direct sql query to the db shows this for this  
field:

— - css - php - Java

The dash added as a field separator is fine, but the 3 dashes at the  
beginning is not… So I tried to find out where these dashes where  
being added, and using the Tamper Data Firefox extension showed me  
that the request was being sent nicely, with the same number of  
parameters that were selected. The next logical step seemed to be to  
check the controller, so I added the following code to the default  
create method:

def create  
string = params[:vacancy].fetch(“tech”)  
@vacancy = Vacancy.new(params[:vacancy])  
if @vacancy.save  
flash[:notice] = string  
redirect\_to :action =\> ‘list’  
else  
render :action =\> ‘new’  
end  
end

But the string that gets flashed shows again only the parameters  
select, without any field separators or the first three dashes.  
What’s going on? What am I missing here? How do I get rid of the  
dashes? Again, apologies if I am asking a very stupid question…

Best,

Fernando
