{"id":25561296,"url":"https://github.com/platanus/activeadmin_jobs","last_synced_at":"2025-08-12T10:13:47.845Z","repository":{"id":9116933,"uuid":"56876643","full_name":"platanus/activeadmin_jobs","owner":"platanus","description":"It's a Rails engine that allows you to play nice with Active Job in Active Admin providing user feedback","archived":false,"fork":false,"pushed_at":"2022-12-14T02:05:43.000Z","size":1554,"stargazers_count":34,"open_issues_count":17,"forks_count":9,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-07-27T09:35:56.941Z","etag":null,"topics":["activeadmin","activejob","error-feedback","feedback","job-notifier","rails","user-feedback"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/platanus.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-22T18:22:30.000Z","updated_at":"2025-03-06T16:35:09.000Z","dependencies_parsed_at":"2023-01-13T15:10:50.775Z","dependency_job_id":null,"html_url":"https://github.com/platanus/activeadmin_jobs","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/platanus/activeadmin_jobs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platanus%2Factiveadmin_jobs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platanus%2Factiveadmin_jobs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platanus%2Factiveadmin_jobs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platanus%2Factiveadmin_jobs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/platanus","download_url":"https://codeload.github.com/platanus/activeadmin_jobs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/platanus%2Factiveadmin_jobs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268322440,"owners_count":24231819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activeadmin","activejob","error-feedback","feedback","job-notifier","rails","user-feedback"],"created_at":"2025-02-20T18:20:03.256Z","updated_at":"2025-08-12T10:13:47.814Z","avatar_url":"https://github.com/platanus.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Active Admin Jobs\n[![Gem Version](https://badge.fury.io/rb/activeadmin_jobs.svg)](https://badge.fury.io/rb/activeadmin_jobs)\n[![Build Status](https://secure.travis-ci.org/platanus/activeadmin_jobs.svg?branch=master)](http://travis-ci.org/platanus/activeadmin_jobs)\n\nIt's a Rails engine that allows you to play nice with [Active Job](https://github.com/rails/activejob) in [Active Admin](https://github.com/activeadmin/activeadmin) providing user feedback.\n\n- An Active Admin's index view to list jobs.\n- An Active Admin's show view to see job details with a special panel to show success/error feedback. To achieve this we are going to use the [Job Notifier](https://github.com/platanus/job_notifier) gem.\n- A way to customize the success and error partials.\n- A mechanism to listen job status changes and notify them using [jQuery Growl](http://ksylvest.github.io/jquery-growl/)\n\n## Installation\n\nAdd to your Gemfile:\n\n```ruby\nsource 'https://rails-assets.org' do\n  gem 'rails-assets-growl', '~\u003e 1.3.1'\nend\n\ngem \"activeadmin_jobs\"\n```\n\n```bash\nbundle install\n```\n\n```bash\nrails generate activeadmin_jobs:install\n```\n\nIf you use `AdminUser` class in `ActiveAdmin` you will need to add the following code:\n\n```ruby\nclass AdminUser \u003c ActiveRecord::Base\n  include JobNotifier::Identifier\n  identify_job_through(:id, :email)\n\n  # more code...\nend\n\n```\n\n## Usage\n\nTo make it easy I'm going to explain how to use this gem with an example.\n\nExample:\n\nAs an **admin user**:\n\n1. From a form, I want to pick a big .xls file containing users information.\n2. In the endpoint pointed by the form, I want to create a job to parse that heavy file in background to create users in the system.\n3. I need a way to know when the process is completed.\n4. Also, I want to see success and error feedback.\n\n\u003cimg src=\"./docs/images/jobs-example.gif\" height=\"500\" /\u003e\n\nNext, I will explain how to solve each step:\n\n#### Step 1: pick the file.\n\nSuppose you want to go to the import form from the `AdminUser`'s index page. To do that, you can add an `action_item` with a `collection_action`:\n\n*/your_app/app/admin/admin_users.rb*\n\n```ruby\nActiveAdmin.register AdminUser do\n  # more code...\n  action_item :import_users, only: :index do\n    link_to \"Import Users\", import_form_admin_admin_users_path\n  end\n\n  collection_action :import_form, title: \"Import Users\" do\n    # Nothing here. We just want to render the form.\n  end\nend\n```\n\nWith the related wiew:\n\n*your_app/app/views/admin/admin_users/import_form.html.erb*\n\n```erb\n\u003c%= semantic_form_for :data, url: { action: :import }, method: :post do |f| %\u003e\n  \u003c%= f.inputs \"Form\" do %\u003e\n    \u003c%= f.input :source, as: :file, label: \"File\", :hint =\u003e \"Excel file with thousands rows that need to be processed in background...\" %\u003e\n  \u003c% end %\u003e\n  \u003c%= f.actions do %\u003e\n    \u003c%= f.action :submit, as: :button, label: \"Import\" %\u003e\n  \u003c% end %\u003e\n\u003c% end %\u003e\n```\n\n\u003cimg src=\"./docs/images/import-form.png\" height=\"300\" /\u003e\n\nYou need to add the endpoint pointed in the form action too.\n\n*/your_app/app/admin/admin_users.rb*\n\n```ruby\nActiveAdmin.register AdminUser do\n  # more code...\n  collection_action :import, title: \"Import Users\", method: :post do\n    # We fill this in the next step.\n  end\nend\n```\n\n#### Step 2: create a job.\n\nInside the import action definition, you need to call the job in charge of parsing the .xls file. To do this:\n\nFirst, we need to create the job. We need to do it using `perform_with_feedback` method provided by [Job Notifier](https://github.com/platanus/job_notifier) gem. You can see how it works reading the **Third and Fourth Steps** of the [usage section](https://github.com/platanus/job_notifier#usage).\n\n*/your_app/app/jobs/user_upload_job.rb*\n\n```ruby\nclass UserUploadJob \u003c ActiveJob::Base\n  def perform_with_feedback(xls_path)\n    # Here you need to process the file an return a success or error result.\n    #\n    # Lets say I'm going to return this message:\n    #\n    # \"Users successfully loaded\"\n    #\n    # with a successful result and something like this:\n    #\n    # errors = [\n    #   { row: 4, errors: [\"Invalid First Name\", \"Invalid Category\"] },\n    #   { row: 6, errors: [\"Invalid Last Name\"] },\n    #   { row: 84, errors: [\"Invalid ID\"] }\n    # ]\n    #\n    # raise JobNotifier::Error::Validation.new(errors)\n    #\n    # with unsuccessful result.\n  end\nend\n\n```\n\nThen, we call the job in the import action:\n\n*/your_app/app/admin/admin_users.rb*\n\n```ruby\nActiveAdmin.register AdminUser do\n  # more code...\n  collection_action :import, title: \"Import Users\", method: :post do\n    file_path = get_file_path(params[:data][:source]) # I'm not going to implement this. It's just an example.\n    UserUploadJob.perform_later(current_admin_user.job_identifier, file_path)\n  end\nend\n```\n\n#### Step 3: notify process completion.\n\nYou don't need to do nothing here, the gem will do it for you using [jQuery Growl](http://ksylvest.github.io/jquery-growl/).\n\nOn success...\n\n\u003cimg src=\"./docs/images/success-notification.png\" height=\"300\" /\u003e\n\nOn error...\n\n\u003cimg src=\"./docs/images/error-notification.png\" height=\"300\" /\u003e\n\n#### Step 4: show success and error feedback.\n\nThe gem includes an index view for jobs. There, you can see a jobs list with the current state of each job.\n\n\u003cimg src=\"./docs/images/jobs-list.png\" height=\"400\" /\u003e\n\nTo show feedback, you need to add one partial by possible job state prefixed by the job's class name in snake_case. For example:\nIf you have the `UserUploadJob` job, following the convention: `_[job_class_name].[job_state].html.erb`, you will need two partials:\n\nOne for success...\n\n*/your_app/app/views/admin/jobs/_user_upload_job.finished.html.erb*\n\n```erb\n\u003c%= result %\u003e\n```\n\n\u003e Remember: we get this: \"Users successfully loaded\" as `result` on success.\n\n\u003cimg src=\"./docs/images/success-view.png\" height=\"400\" /\u003e\n\nOne for error...\n\n*/your_app/app/views/admin/jobs/_user_upload_job.failed.html.erb*\n\n```erb\n\u003ch2\u003eErrors :(\u003c/h2\u003e\n\n\u003c% result.each do |record| %\u003e\n  \u003ch3\u003eRow #\u003c%= record[:row] %\u003e:\u003c/h3\u003e\n  \u003cul\u003e\n    \u003c% record[:errors].each do |error| %\u003e\n      \u003cli\u003e\u003c%= error %\u003e\u003c/li\u003e\n    \u003c% end %\u003e\n  \u003c/ul\u003e\n\u003c% end %\u003e\n```\n\n\u003e Remember: we get something like this:\n```ruby\n[\n  { row: 4, errors: [\"Invalid First Name\", \"Invalid Category\"] },\n  { row: 6, errors: [\"Invalid Last Name\"] },\n  { row: 84, errors: [\"Invalid ID\"] }\n]\n```\nas `result` on error.\n\n\u003cimg src=\"./docs/images/error-view.png\" height=\"600\" /\u003e\n\nThose partials will be rendered in the job's show view depending on its state.\n\n## I18n\n\nIf you want to translate your notifications, you can do it following this convention:\n\n**/your_app/config/locales/en.yml**\n\n```yml\nen:\n  activeadmin_jobs:\n    [job_class_name]:\n      description: \"XXX\"\n      finished:\n        title: \"XXX\"\n        one: \"XXX\"\n        other: \"XXX\"\n      failed:\n        title: \"XXX\"\n        one: \"XXX\"\n        other: \"XXX\"\n```\n\nFor example:\n\n```yml\nen:\n  activeadmin_jobs:\n    user_upload_job:\n      description: \"Users upload through .xls file\"\n      finished:\n        title: \"Users have been uploaded! :)\"\n        one: \"One .xls file was completed with no errors. Click here to see the result\"\n        other: \".xls files were completed with no errors. Click here to see the result\"\n      failed:\n        title: \"Error trying to upload users :(\"\n        one: \"One .xls file could not be uploaded. Click here to see errors\"\n        other: \".xls files could not be uploaded. Click here to see errors\"\n```\n\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## Credits\n\nThank you [contributors](https://github.com/platanus/activeadmin_jobs/graphs/contributors)!\n\n\u003cimg src=\"http://platan.us/gravatar_with_text.png\" alt=\"Platanus\" width=\"250\"/\u003e\n\nActive Admin Jobs is maintained by [platanus](http://platan.us).\n\n## License\n\nActive Admin Jobs is © 2016 platanus, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatanus%2Factiveadmin_jobs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplatanus%2Factiveadmin_jobs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplatanus%2Factiveadmin_jobs/lists"}