What I am trying to do is to come up with the model for Project, where only one project could be active at a time. So I am thinking to create one table for projects and another one for status.
How can I make sure that only one project is active at a given time ? I looked into validates_uniqueness_of but I am little confused if thats the solution for me, because I do want to able to override the current status, despite the fact if one project is already enabled.
Your
Projectshould have something like an:activeattribute. You can then add validation like this on yourProjectmodelNow, if a
Projectalready is active, and have another (currently inactive)Project@project, and try to do@project.errorswill contain a Hash with:activeattribute having the above error sinceProjectis already activeProjectwe’re saving.