On Sun, Sep 13, 2009 at 6:52 AM, arwed <af-0WR/Tm5k6cQ@public.gmane.org>
wrote:>
> 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
I''d use merge right about here:
params[:movie].merge( :days => days.join('','') )
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 Donald
http://destiney.com/