Home Is there a way to update a field in rails if same value exists for a different field maintaining its uniqueness?
Reply: 0

Is there a way to update a field in rails if same value exists for a different field maintaining its uniqueness?

user594
1#
user594 Published in June 23, 2018, 4:23 am

I am working on user's model in which users will be sorted on the basis of sort_order for them. What I am trying to achieve is that if we set same sort_order for a new user or update existing user, all users with same sort_order are incremented. For example we have 3 user types with their sort_order as follows


Gold with sort_order as 1

Diamond with sort_order as 2

Platinum with sort_order as 3


Updating Gold to 2 should result in Diamond increasing to 3 and Platinum increasing to 4.

Is there a way to do this in Rails?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.314337 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO