Oh, yeah, thanks Arthur. What was I thinking... :/ On Tuesday, September 4, 2012 5:03:02 PM UTC+2, Arthur MM wrote: > > well, from the api > http://rubydoc.info/gems/dm-core/1.1.0/DataMapper/Model:first_or_createit > will always return a object model. So, you would have to do a find first. > > 2012/8/19 manu <etab...@gmail.com <javascript:>> > >> Hello >> >> I'm trying to branch based on the return value of first_or_create, but >> something eludes me. >> >> flight = Flight.first_or_create({:avatar_id => avatar.id, :mission_id => >> mission.id} , {:monture_id => monture.id, :role_id => role.id, :temps_vol >> => params[:temps_vol], :statutfinmission_id => statut.id}) >> >> When the user submits a new Flight entry, I first check if an entry >> already exists (using the table's composite key avatar.id + mission.id). >> >> But as I understand it, flight will always return true, whether it >> creates a new record or finds one already existing. Is this correct? Is >> there anyway to differentiate between the two cases? >> >> Thx a bunch. >> >> -- >> 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/-/uhx12rVuVrwJ. >> To post to this group, send email to datam...@googlegroups.com<javascript:> >> . >> To unsubscribe from this group, send email to >> datamapper+...@googlegroups.com <javascript:>. >> 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 >
-- 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/-/cvx_bo9SBVoJ. To post to this group, send email to datamapper@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.