# How to add multiple weekdays into one field

**URL:** <https://www.ruby-forum.com/t/how-to-add-multiple-weekdays-into-one-field/175417>\
**Category:** Rails\
**Created:** [September 13, 2009, 1:54pm UTC](https://www.ruby-forum.com/t/how-to-add-multiple-weekdays-into-one-field/175417 "2009-09-13T13:54:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![arwed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@arwed](https://www.ruby-forum.com/u/arwed)\
**Post date:** [September 13, 2009, 1:54pm UTC](https://www.ruby-forum.com/t/how-to-add-multiple-weekdays-into-one-field/175417/1 "2009-09-13T13:54:11Z")

</div>

newbee question:

I have a form, where I want to add a choice of weekdays a movie is  
playing into one field:

\<%= select\_tag ‘days[]’, options\_for\_select([[“monday”, “2”],  
[“tuesday”, “3”], [“wednesday”, “4”], [“thursday”, “5”], [“friday”,  
“6”], [“saturday”, “7”], [“sunday”, “1”]]),:multiple =\> true %\>

how can I save days.join(",") into @movie.weekdays when I create a new  
movie record?

def create  
@movie = Movie.new(params[:movie])  
respond\_to do |format|  
if @movie.save  
flash[:notice] = ‘Movie was successfully created.’  
format.html { redirect\_to(movies\_path) }  
else  
format.html { render :action =\> “new” }  
end  
end  
end

---

<div class="post-metadata">

**Author:** ![arwed](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@arwed](https://www.ruby-forum.com/u/arwed)\
**Post date:** [September 13, 2009, 5:13pm UTC](https://www.ruby-forum.com/t/how-to-add-multiple-weekdays-into-one-field/175417/2 "2009-09-13T17:13:11Z")

</div>

On Sun, Sep 13, 2009 at 6:52 AM, arwed [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> how can I save days.join(“,”) into @movie.weekdays when I create a new  
> movie record?
> 
> def create

I’d use merge right about here:

params[:movie].merge( :days =\> days.join(‘,’) )

[http://www.ruby-doc.org/core/classes/Hash.html#M002880](http://www.ruby-doc.org/core/classes/Hash.html#M002880)

> @movie = Movie.new(params[:movie])  
> respond\_to do |format|  
> if @movie.save  
> flash[:notice] = ‘Movie was successfully created.’  
> format.html { redirect\_to(movies\_path) }  
> else  
> format.html { render :action =\> “new” }  
> end  
> end  
> end

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)
