Why not have a:
class FeaturedProject < ActiveRecord::Base
self.class.count < 1
Then you can FeaturedProduct.find(:first) and be sure that there is
only one. No need to mess with the projects when the featured one
changes. However, you might want to do:
fp = FeaturedProject.find(:first)
if fp && fp.project_id == self.id
Although that might be equivalent to:
has_one :featured_project, :dependent => :destroy
On Feb 18, 2009, at 12:43 PM, yaphi wrote:
point of view.
I’m not sure if there is a term for this (which is why I can’t find
anything on google) but I want to be able to set one of my models
active, where the rest will be set to inactive.
I would guess to write a method that sets all the records to
then set the selected object to active. That seems like it’s pretty
messy though. Is there some sort of built-in functionality with
that will only allow one column to be true at a time?
Rob B. http://agileconsultingllc.com