{"id":15503048,"url":"https://github.com/johno/archivable","last_synced_at":"2025-04-22T23:21:38.738Z","repository":{"id":16257147,"uuid":"19005187","full_name":"johno/archivable","owner":"johno","description":"Archive your Rails models rather than delete them","archived":false,"fork":false,"pushed_at":"2018-04-10T14:49:48.000Z","size":33,"stargazers_count":9,"open_issues_count":3,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-19T17:30:46.307Z","etag":null,"topics":[],"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/johno.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-04-21T20:02:49.000Z","updated_at":"2020-08-27T03:42:16.000Z","dependencies_parsed_at":"2022-09-10T17:21:33.698Z","dependency_job_id":null,"html_url":"https://github.com/johno/archivable","commit_stats":null,"previous_names":["johnotander/archivable"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johno%2Farchivable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johno%2Farchivable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johno%2Farchivable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johno%2Farchivable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johno","download_url":"https://codeload.github.com/johno/archivable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250338502,"owners_count":21414198,"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","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":[],"created_at":"2024-10-02T09:11:56.956Z","updated_at":"2025-04-22T23:21:38.721Z","avatar_url":"https://github.com/johno.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# archivable [![Build Status](https://travis-ci.org/johnotander/archivable.svg?branch=master)](https://travis-ci.org/johnotander/archivable)\n\nArchive your Rails models rather than delete them. This provides the archiving functionality app so you can do the following:\n\n##### In your models\n\n```ruby\nuser.archived?  #=\u003e false\nuser.archive!   #=\u003e true\nuser.archived?  #=\u003e true\nuser.unarchive! #=\u003e true\nuser.archived?  #=\u003e false\n```\n\n##### In your views\n\n```html+erb\n\u003c% if user.archived? %\u003e\n  \u003c%= link_to :Archive, archive_user_path(user) %\u003e\n\u003c% else %\u003e\n  \u003c%= link_to :Unarchive, archive_user_path(user) %\u003e\n\u003c% end %\u003e\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'archivable'\n```\n\nAnd then execute:\n\n```\n$ bundle\n```\n\nOr install it yourself as:\n\n```\n$ gem install archivable\n```\n\n## Usage\n\n### Database Migration\n\nFirst, you need to add the `archived` column to your model (which we we call `User` for this example):\n\n```\n$ rails g migration add_archived_to_users archived:boolean\n$ rake db:migrate\n```\nNOTE: remember to edit the migration and set `:archived` column to default to `false` in order to simplify querying for non-archived models.\n\n```\n  add_column :users, :archived, :boolean, default: false\n```\n\n### Application Routes\n\nIn your routes file (`config/routes.rb`):\n\n```ruby\nMy::Application.routes.draw do\n  resources :users do\n    get archive,  on: :member\n    get archived, on: :collection\n  end\nend\n```\n\n### The Model\n\nNext, you need to include the model concern to gain access to some handy methods.\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  include Archivable::Model\n\n  # ...\nend\n```\n\n### The Controller\n\nLastly, you need to include the controller concern to handle the controller actions.\n\n```ruby\nclass UsersController \u003c ApplicationController\n  include Archivable::Controller\n\n  def index\n    @users = User.where(archived: false)\n  end\n\n  # ...\nend\n```\n\n### That's it.\n\nNow, instead of a delete link, you can do the following:\n\n```html+erb\n\u003c%= link_to user.archived? ? :Unarchive : :Archive, archive_user_path(user) %\u003e\n\u003c%= link_to 'See Archived Users', archived_users_path %\u003e\n```\n\n## Contributing\n\n1. Fork it ( http://github.com/johnotander/archivable/fork )\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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohno%2Farchivable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohno%2Farchivable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohno%2Farchivable/lists"}