mercredi 19 avril 2017

How to call event in another model?

I am using the workflow gem.

class Article
  include Workflow
  workflow do
    state :new do
      event :submit, :transitions_to => :awaiting_review
    end
    state :awaiting_review do
      event :review, :transitions_to => :being_reviewed
    end
    state :being_reviewed do
      event :accept, :transitions_to => :accepted
      event :reject, :transitions_to => :rejected
    end
    state :accepted
    state :rejected
  end
end

In same Article class I can call the event by doing this:

article = Article.new
article.submit!

But what if i want to call this event in other model file?

Aucun commentaire:

Enregistrer un commentaire