I need to keep version of a model Client: has_many :product_clients has_many :products, :through => :product_clients The question is what is the best way of saving versions of the association. Can I make the association using the client.version.id rather than the client.id? Or should I use a bit mask? Any thoughts much appreciated, Mike -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
mikej wrote:> I need to keep version of a model Client: > > has_many :product_clients > has_many :products, :through => :product_clients > > The question is what is the best way of saving versions of the > association. Can I make the association using the client.version.id > rather than the client.id? Or should I use a bit mask? > > Any thoughts much appreciated, > > MikeWhat about adding a datetime start and a datetime end to the product_clients model - expand it out to a full join table with additional attributes? Don''t delete the relationship, just end it. Then you could view which products a client had on any given date, today or in the past. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That would work.  I like the idea of making my clients serial
monogamists.
However, it is a bit of a faff having to pass a date every time, or
perhaps I could write this into the has_many relationship.  Am I
missing something?
I''ve just added a version_id (populated with the version number)  to
the product_clients and added to the association:
  has_many :product_clients :dependent => :destroy, :conditions =>
''product_clients.version_id =
#{self.send("version")}''
  has_many :products, :through => :product_clients
Does this seem sensible?
Mike
-- 
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.