{"id":13879159,"url":"https://github.com/bigbinary/acts_in_sequence","last_synced_at":"2025-03-29T20:43:34.359Z","repository":{"id":45218148,"uuid":"279582306","full_name":"bigbinary/acts_in_sequence","owner":"bigbinary","description":"Adds sequencing to the database records.","archived":false,"fork":false,"pushed_at":"2021-12-30T18:49:10.000Z","size":21,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-04T21:43:21.187Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bigbinary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-14T12:43:45.000Z","updated_at":"2022-12-11T15:25:28.000Z","dependencies_parsed_at":"2022-07-19T00:02:09.542Z","dependency_job_id":null,"html_url":"https://github.com/bigbinary/acts_in_sequence","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigbinary%2Facts_in_sequence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigbinary%2Facts_in_sequence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigbinary%2Facts_in_sequence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bigbinary%2Facts_in_sequence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bigbinary","download_url":"https://codeload.github.com/bigbinary/acts_in_sequence/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246243565,"owners_count":20746307,"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-08-06T08:02:11.682Z","updated_at":"2025-03-29T20:43:34.334Z","avatar_url":"https://github.com/bigbinary.png","language":"Ruby","readme":"# ActsInSequence\n\n[![bigbinary](https://circleci.com/gh/bigbinary/acts_in_sequence/tree/master.svg?style=shield)](https://app.circleci.com/pipelines/github/bigbinary)\n\n\nAdds sequencing to the database records.\n\nOften we want to keep a record `sequence`/`order` in the database. This gem takes care of adding sequence (auto-incremented) to newly added records.\n\nTough its not just auto-increment, you can do [scoped sequencing](#scope) and more with this gem.\n\n## Usage\n\n### Install\n\n```ruby\ngem 'acts_in_sequence', git: 'https://github.com/bigbinary/acts_in_sequence'\n```\n\n```ruby\nbundle install\n```\n\n### Create Migration\n\n```ruby\nbin/rails generate migration AddSequenceTo{MODEL_NAME} sequence:integer\n```\n\n### Enable Sequencing\n\nBy default, `acts_in_sequence` assumes the records sequence is stored in `sequence` column of type `integer`.\n\n```ruby\nclass Task \u003c ActiveRecord::Base\n  acts_in_sequence\nend\n```\n\n#### Scope\nThis attribute allows us to track sequencing with a scope.\n\n```ruby\nclass TodoList \u003c ActiveRecord::Base\n  has_many :tasks\nend\n\nclass Task \u003c ActiveRecord::Base\n  acts_in_sequence scope: :todo_list\n\n  belongs_to :todo_list\nend\n```\n\nYou can scope on any column ( Yeah, thats right! )\n\n```ruby\nclass Task \u003c ActiveRecord::Base\n  acts_in_sequence scope :name\nend\n```\n\n#### Custom column name\nWith `:column_name` we can use custom column names instead of using `sequence`.\n\n```ruby\nclass Task \u003c ActiveRecord::Base\n  acts_in_sequence column_name: :display_order\nend\n```\n\n#### Default order\nWhen sequencing is applied, records will be sorted with `ASC` sequence by default. Use `default_order` attribute to change it when you need to.\nUse scope `without_sequence_order` when you want to remove the default ordering.\n\n```ruby\nclass Task \u003c ActiveRecord::Base\n  acts_in_sequence\nend\n\nclass Item \u003c ActiveRecord::Base\n  acts_in_sequence default_order: :desc\nend\n\nTask.all                        # =\u003e 1, 2, 3, 4, 5\nItem.all                        # =\u003e 5, 4, 3, 2, 1\nItem.without_sequence_order.all # =\u003e 1, 2, 3, 4, 5\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigbinary%2Facts_in_sequence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbigbinary%2Facts_in_sequence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbigbinary%2Facts_in_sequence/lists"}