-
Notifications
You must be signed in to change notification settings - Fork 0
Example of delayed_jobs resource configuration
Lukas Svoboda edited this page Jan 1, 2014
·
2 revisions
To see the delayed_jobs table at localhost:3000/delayed_jobs you need to set:
- routes
- controller
- ...and add delayed_jobs model to the rails_admin
Add delayed_jobs model to the file config/initializers/rails_admin.rb:
config.included_models = Lepidlo::Utils.detect_models + ['Delayed::Job']
Confing routes:
concern :resourcable do
get 'options', :on => :collection
get 'query', :on => :collection
post 'query', :on => :collection
get 'export', :on => :collection
post 'export', :on => :collection
get 'import', :on => :collection
post 'import', :on => :collection
patch 'import', :on => :collection
delete 'import', :on => :collection
end
resources :delayed_backend_active_record_jobs, concerns: [:resourcable], path: :delayed_jobs, controller: :delayed_jobs
Create controller app/controllers/delayed_jobs_controller.rb:
class DelayedJobsController < ResourcesController
defaults resource_class: Delayed::Job,
route_collection_name: 'delayed_backend_active_record_jobs',
route_instance_name: 'delayed_backend_active_record_job'
def list_form
list_form! do |form|
form.hide_fields :handler, :last_error
end
end
def show_form
show_form! do |form|
[:handler, :last_error].each do |n|
f = form.field(n)
def f.pretty_value
form.view.content_tag(:pre, value)
end
end
end
end
end
You need to add (uncomment) following line in the lib/generators/basepack/templates/import.rb
file.
handle_asynchronously :import_data