On Sun, Sep 13, 2009 at 6:52 AM, arwed <[email protected]> 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/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to