Forum: Ruby on Rails Feed 2 tables with one Form

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
irong (Guest)
on 2006-05-18 04:54
hi all,

i have a form with several datas given by the user : name, adress , tel
When the user press "create" i call an action called "create_stagiaire"
which create his account but i also want to feed another table named
"demandes" where which i feed with a date given by the user. In my form
this date field is writen like this :
<%= date_select 'demande', 'dr'%>

No problem and here is the action :

  def create_stagiaire
     @stagiaire =[:stagiaire])
      flash[:notice] = 'Stagiaire was successfully created.'
      redirect_to :action => 'list'
      render :action => 'new'

My probleme is that, it creates an entry in the "stagiaires" table with
no problem, but not in the "demandes" table :(

here the error : Mysql::Error: #23000Column 'dr' cannot be null: INSERT
INTO demandes (`dr`, `type`, `stagiaire_id`) VALUES(NULL, '', 13)

i supposed that i did something wrong near :
@stagiaire.demandes.create(params[:dr]) thks
Chris H. (Guest)
on 2006-05-18 18:33
(Received via mailing list)
wouldn't it be:

This topic is locked and can not be replied to.