I''m having some problems with acts_as_versioned. All my foo_versions have the same version id. Description by example:> ruby script/consoleLoading development environment.>> p = Product.find_by_id 1[...]>> p.versions.size=> 6>> p.versions.each { |version|?> puts version.id>> }1 2 3 4 5 6 [...]>> p.find_version 1=> #<Item::Version:0x8ed788c @attributes={"item_id"=>"1", "name"=>"", "visible"=>"1", "brand_id"=>"1", "updated_at"=>"2006-11-24 16:34:01", "code"=>"", "title"=>"", "versioned_type"=>"Product", "creator_id"=>"1", "id"=>"1", "version"=>"1", "heading"=>"", "description"=>"", "updater_id"=>"1", "created_at"=>"2006-11-24 16:34:01"}> [some content removed]>> p.find_version 2=> nil>> p.find_version 3=> nil>> p.find_version 4=> nil>> p.find_version 5=> nil>> p.find_version 6=> nil Looking at the Database: sqlite> select version from item_versions; 1 1 1 1 1 1 Is this because I''m using inheritance? The structure is: Element (editable, versionable, etc) > Item (purchaseable) > Product (single item, no special discounts, etc) I''ve tried to move as much of the logic for each layer to the bottom of the heap. Thus my Element class looks like this:> cat app/models/element.rbclass Element < ActiveRecord::Base public self.abstract_class = true has_one :creator, :class_name => ''Editor'', :foreign_key => :id has_one :updater, :class_name => ''Editor'', :foreign_key => :id validates_presence_of :created_at, :on => :update validates_presence_of :updated_at, :on => :update validates_inclusion_of :visible, :in => 0..1 end How can I nail down the issue? My guess is that acts_as_versioned is thinking I''m always making a version 1 as it is looking at Item or Product where it shouldn''t be. Any help or criticisms of the approach I have taken above appreciated. This is mostly a proof of concept for a possible piece of further development at the moment. Thanks! Dominic --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
djwmarks wrote:> How can I nail down the issue? My guess is that acts_as_versioned is > thinking I''m always making a version 1 as it is looking at Item or > Product where it shouldn''t be. Any help or criticisms of the approach I > have taken above appreciated. This is mostly a proof of concept for a > possible piece of further development at the moment.Are you using optimistic locking in your tables? acts_as_versioned will use the version_lock field as the version number instead of the "version" field if it exists. If that is the case then "version" becomes just a normal field and does not automatically increment. Eric --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, 28 Nov 2006 09:03:25 -0500 Eric Anderson <eric-ANzg6odk14w@public.gmane.org> wrote:> > djwmarks wrote: > > How can I nail down the issue? My guess is that acts_as_versioned is > > thinking I''m always making a version 1 as it is looking at Item or > > Product where it shouldn''t be. Any help or criticisms of the approach I > > have taken above appreciated. This is mostly a proof of concept for a > > possible piece of further development at the moment. > > Are you using optimistic locking in your tables? acts_as_versioned will > use the version_lock field as the version number instead of the > "version" field if it exists. If that is the case then "version" becomes > just a normal field and does not automatically increment.I see. I am indeed using optimistic locking. I think I may be making a problem for my self as although I have inheritance in place I am not using STI. The Product class sets its table to products, there is no items table in the database. However I do have item_versions table, and it sets the versioned_type attribute correctly to Product. I''m constructing the versioned_table with a migration and the create_versioned_table method. I''m going to play around a little more and see if I can get a little further myself. Is there a way of getting the the queries being sent to SQLite in ruby script/console or script/server? That would be a big help. Thanks! Dominic --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dominic Marks wrote:> I''m going to play around a little more and see if I can get a > little further myself. Is there a way of getting the the > queries being sent to SQLite in ruby script/console or > script/server? That would be a big help.The log files should have them. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---