error when attempting to create record with "not required" field

40 views
Skip to first unread message

manu

unread,
Aug 19, 2012, 6:58:14 AM8/19/12
to datam...@googlegroups.com
Yes ain't I the verbose one today :)

So I discovered today after much blood and tears that, even if a field is not required in my model, it will throw an exception if I try to create a new record where that particular field is empty (when I leave the text input empty on my form).

That seems strange, it can't be right, can it?

For now I have a horrible work around where I check if that field is empty at POST and create a different Model.create statement based on that check...

Could someone please shine some light on me? I must be doing something wrong here.

-M

Arthur M. Meskelis

unread,
Sep 4, 2012, 10:53:27 AM9/4/12
to datam...@googlegroups.com
it's really bizarre, can you post some code to us ?

2012/8/19 manu <etab...@gmail.com>

-M

--
You received this message because you are subscribed to the Google Groups "DataMapper" group.
To view this discussion on the web visit https://groups.google.com/d/msg/datamapper/-/AacDbQKZF98J.
To post to this group, send email to datam...@googlegroups.com.
To unsubscribe from this group, send email to datamapper+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.



--
------------------------------------------
 1. Notebook para você ficar livre e programar a vontade: R$ 2300
 2. Curso de Programação/SysAdmin/DBA: R$ 5000
 3. Pedir a solução pronta para um problema numa lista de discussão: Não tem preço !

E para todas as outras existe RTFM, STFW e  LMGTFY

manu

unread,
Sep 19, 2012, 9:58:53 AM9/19/12
to datam...@googlegroups.com
Sure. here's the model:

and then the post method with the horrible work-around when the :temps_vol input is blank:

post '/cr_mission' do

  (params[:temps_vol] == "") ? temps_vol="00:00":temps_vol=params[:temps_vol]
  
  flight = Flight.first_or_create({:avatar_id => params[:choix_avatar],
                                   :mission_id => params[:choix_mission]
                                   },
                                  {:monture_id => params[:choix_monture],
                                   :role_id => params[:choix_role],
                                   :temps_vol => temps_vol,
                                   :statut_fin_mission_id => params[:choix_statut]
                                   })
  
  redirect '/cr_mission'
end

the form can be found here:

ps: sorry for late respond, was AFK for two weeks :)
Reply all
Reply to author
Forward
0 new messages