On 10 March 2011 21:00, danm <dmuch...@gmail.com> wrote:
> I've got something weird happening in the code (using Rails 3.0).  I
> have a ton of has_many/belongs_to relationships in my application and
> I save the child objects like this:
>
> if parent.child_collection << child
>  #do success code
> else
>  #do error code
> end
>
> The problem is that this ends up with duplicate child records in the
> database, saved two seconds apart.  The weird part is that this
> happens when the user is using IE or Chrome, but NOT when using
> Firefox.  I'm wondering if this is Javascript related (I'm using
> jQuery), but I do get two "Success" messages in Firefox even though it
> only saves once.  The #do success code uses Ajax to put up a view of
> the parent object with the children in a table.

Can you not see what is happening by carefully examining the log file
(log/development.log)?  For example if two requests were being made
you should see that there.

Another thought, have you validated the full page html in the w3c html
validator?  Differences between browsers is often a sign of malformed
html.  Also check in the firebug plugin in firefox that there are no
javascript errors.

Colin

Colin

>
> Should I explicitly save the child before I add it to the collection?
> This code seemed to work just fine before I "AJAX-ified" the
> application, but then I always use Firefox for development
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to