well, from the api
http://rubydoc.info/gems/dm-core/1.1.0/DataMapper/Model:first_or_create it
will always return a object model. So, you would have to do a find first.

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

> 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 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.
>



-- 
------------------------------------------
 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 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.

Reply via email to