Ruby on Rails Friday, April 22, 2016

On 21 April 2016 at 23:21, Meenakshi Sharma <meenakshi8@gmail.com> wrote:
> Hi all,
>
> I am running into 'concurrent POST requests' issue in the application that I
> would like to handle.
> It's resulting in duplicate entries in database for columns with indexes.
>
> I am thinking of adding unique constraint to the table columns (with index)
> and handle resulting database errors in the application.

If you have a uniqueness validation then you should always also
enforce that in the database, for exactly the reason you describe.
See
http://guides.rubyonrails.org/active_record_validations.html#uniqueness

Colin

--
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+unsubscribe@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/CAL%3D0gLujNYGaproqOjyWk0XAYCuUm3WOcGsmMsqR%3DPfpbYKS0w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment