Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define workflow with a method in Rails #174

Closed
emclab opened this issue Mar 18, 2016 · 0 comments
Closed

Define workflow with a method in Rails #174

emclab opened this issue Mar 18, 2016 · 0 comments

Comments

@emclab
Copy link

emclab commented Mar 18, 2016

In our Rails 4.2 app. model payment_request has a workflow which is defined within the model. The workflow is defined as:

module PaymentRequestx
require 'workflow'
class PaymentRequest < ActiveRecord::Base
include Workflow
workflow do
#workflow definition
end
end

The above code worked fine. In order to pass a session variable into model, a method add_wf is defined around the workflow in model payment_request:

module PaymentRequestx
require 'workflow'
class PaymentRequest < ActiveRecord::Base
include Workflow

def self.add_wf(session_token)
  workflow do
    #workflow definition
  end
end    

end

The method add_wf is called in before_action in application_controller.

PaymentRequest.add_wf(session_token)

The problem is workflow is not defined after execution. I also tried the active record base:

def self.add_wf(session_token)
  def self.included(base)
    base.workflow do
      #workflow definition
    end
  end
end    

The workflow is still not defined. I guess problem is that the workflow do loop is not executed within the context of model payment request. How to force the execution of workflow do loop within the context of model PaymentRequest?

@geekq geekq closed this as completed May 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants