Question: access current_page? in ApplicationJob

Question

access current_page? in ApplicationJob

Answers 1
Added at 2016-11-04 21:11
Tags
Question

Do I have access to current_page? method in ApplicationJob?

I tried to use it and the job didn't work anymore.

def perform(message)   
  if current_page?(root_path)
    x = 1
  end
end
Answers to

access current_page? in ApplicationJob

nr: #1 dodano: 2016-11-04 22:11

View/controller helpers are not available in ApplicationJob.

You have to pass it as argument:

def perform(message, path)   
  if path == Rails.application.routes.url_helpers.root_path
    x = 1
  end
end

P.S. I am not sure you really want to have performing a job be impacted by a controller path.

Source Show
◀ Wstecz