Forum: Ruby on Rails acts_as_versioned and qa

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
669ad65a6aaefa1b5e6353cea9fe26c0?d=identicon&s=25 Tomasz Bak (linus)
on 2009-03-27 00:10
(Received via mailing list)
Hi,
I have Article model and it has aasm_column qa, that is initially
"pending".

In order to get it reset qa column on new versions, I have made:

  def set_new_version
    write_attribute(:qa, "pending")
  end

But now the aasm methods are also triggering the new version, dispite:

  self.non_versioned_columns << 'updated_at'
  self.non_versioned_columns << 'created_at'
  self.non_versioned_columns << 'qa'
  self.non_versioned_columns << 'published_at'

How to make the approve! method to start working, while data change
should trigger qa reset?

Tom

PS Here is saple code:

class Article < ActiveRecord::Base

  include AASM

  aasm_column :qa
  aasm_initial_state :pending
  aasm_state :pending
  aasm_state :approved
  aasm_state :rejected

  aasm_event :approve do
    transitions :from => :pending, :to => :approved, :guard => :valid?
  end

  aasm_event :reject do
    transitions :from => :pending, :to => :rejected, :guard => :valid?
  end

  acts_as_versioned

  self.non_versioned_columns << 'updated_at'
  self.non_versioned_columns << 'created_at'
  self.non_versioned_columns << 'qa'
  self.non_versioned_columns << 'published_at'

  def set_new_version
    write_attribute(:qa, "pending")
  end

end
This topic is locked and can not be replied to.