1

私は以下のようなモデルを持っています

class Inspection < ActiveRecord::Base
  include AASM

  aasm_column :status  #aasm in 'status' field
  aasm_initial_state :new
  aasm_state :new
  aasm_state :inprocess
  aasm_state :complete
  aasm_state :approved

  aasm_event :inprocess do
    transitions :to => :inprocess, :from => :new
  end

  aasm_event :complete do
    transitions :to => :complete, :from => :inprocess
  end

  aasm_event :approve do
    transitions :to => :approved, :from => :complete
  end


  aasm_column :sharing_status  #aasm in 'sharing_status' field
  aasm_initial_state :not_shared
  aasm_state :not_shared
  aasm_state :shared
  aasm_state :revoked

  aasm_event :share do
    transitions :to => :shared, :from => :not_shared
  end

  aasm_event :revoke do
    transitions :to => :revoked, :from => :shared
  end

  .....
end

検査の2つの異なるモデルフィールドに異なるaasm状態と遷移を実装したいと思います。上記のコードでは、最初の遷移は機能しません(2番目の状態と遷移が存在する場合)。これはどのように解決できますか?

4

1 に答える 1

1

同じ問題がありますが、AASMでは同じモデルに複数の状態モデルを含めることはサポートされていないようですが、プラグイン「state_machine」はこれをサポートしています。

https://github.com/pluginaweek/state_machine

于 2013-10-14T12:29:29.317 に答える