Yeah, It's exactly that... you are creating a user before the Institution... But I your controller isn't searching for some Institution while creating the User... I just see your controller creating an Institution... doesn't matter if already exists...
*Carlos Figueiredo* On Tue, Aug 6, 2013 at 6:20 AM, selva4...@gmail.com <selva4...@gmail.com>wrote: > Hi, > > The @user object is getting saved first. That time, there is no > instuition membership attached to it. So one is getting created. Then > when you save the instuition membership again inside the controller it > also gets saved. > > Is this clear? > > On Sat, Aug 3, 2013 at 2:00 AM, masta Blasta <li...@ruby-forum.com> wrote: > > Matt Jones wrote in post #1117517: > >> On Thursday, 1 August 2013 10:56:06 UTC-4, Ruby-Forum.com User wrote: > >>> if institution_memberships.empty? > >>> > >>> ) > >>> only have one membership per institution, hence the > >>> well enough to pinpoint the exact cause. Obviously there is no need to > >>> create a membership object in the controller, but the code had been > that > >>> way for a long time without a problem. Nobody noticed it until suddenly > >>> the bad data started showing up. I'm more curious as to why the > >>> validation goes through. > >>> > >>> What's the community think? > >>> > >>> > >> Can you post a log of the SQL that gets executed during the transaction? > >> I'm curious about what the validates_uniqueness_of is looking up, if > >> anything. > >> > >> --Matt Jones > > > > > > I attached a part of the log from my functional testing. What i assume > > to be the validation check SELECT statement does not have a user_id yet. > > However the DB INSERT occurring right after, does have the user_id. > > > > Very puzzling. FYI I'm on Rails 2.3.15 > > > > Attachments: > > http://www.ruby-forum.com/attachment/8650/query_log.txt > > > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > -- > > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to rubyonrails-talk+unsubscr...@googlegroups.com. > > To post to this group, send email to rubyonrails-talk@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/6980a8a3360434ff72301fbf698f61c2%40ruby-forum.com > . > > For more options, visit https://groups.google.com/groups/opt_out. > > > > > > > > -- > Azhagu Selvan > > http://tamizhgeek.in > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-talk@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/CABX9Rmz0w5kTE%3Ds2A3tY%2B%2BtdzDKcPpXUL-j4qw-GyCh-Bko3Jg%40mail.gmail.com > . > For more options, visit https://groups.google.com/groups/opt_out. > > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CANPOtXvyDqz_iE_C6A8LE0r58CeNPnC%3DvxGvVB__%3D39%3D_xDG5g%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.