{"id":25725545,"url":"https://github.com/umar221b/arrangeable","last_synced_at":"2025-05-07T06:44:59.869Z","repository":{"id":62553536,"uuid":"240439950","full_name":"umar221b/arrangeable","owner":"umar221b","description":"Arrangeable provides an organized and seamless way to sort your ActiveRecord objects by different attributes.","archived":false,"fork":false,"pushed_at":"2022-10-27T07:19:25.000Z","size":19,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-07T06:44:58.077Z","etag":null,"topics":["activerecord","hacktoberfest","order","rails","ruby","sort"],"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/umar221b.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":"2020-02-14T06:06:29.000Z","updated_at":"2022-10-27T07:01:29.000Z","dependencies_parsed_at":"2022-11-03T04:45:23.377Z","dependency_job_id":null,"html_url":"https://github.com/umar221b/arrangeable","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umar221b%2Farrangeable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umar221b%2Farrangeable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umar221b%2Farrangeable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/umar221b%2Farrangeable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/umar221b","download_url":"https://codeload.github.com/umar221b/arrangeable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252831178,"owners_count":21810779,"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":["activerecord","hacktoberfest","order","rails","ruby","sort"],"created_at":"2025-02-25T22:30:39.479Z","updated_at":"2025-05-07T06:44:59.829Z","avatar_url":"https://github.com/umar221b.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arrangeable\n\nArrangeable provides an organized and seamless way to sort your ActiveRecord objects by different attributes.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'arrangeable', '~\u003e 0.1.5'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install arrangeable\n\n## Usage\n\nInclude Arrangeable inside ApplicationRecord or directly inside your ActiveRecord model and override the `arrangeable_fields` method for each model to whitelist the fields you want to use for sorting:\n\n```ruby\nclass User \u003c ApplicationRecord\n  include Arrangeable\n\n  concerning :Arranging do\n    class_methods do\n      def arrangeable_fields\n        %w[id first_name last_name]\n      end\n    end\n  end\nend\n```\n\nFailing to override `arrangeable_fields` will raise a `NotImplementedError`.\n\nNow sort your objects by calling `arrange` on your model and passing a comma-separated order string. Prepend a negative sign `-` before a key to order by that key descendingly:\n\n```ruby\n\n@users = User.all\n\norder_string = 'first_name,-id'\n@users = @users.arrange(order_string)\n```\n\nThe previous example will generate the following SQL order clause: `ORDER BY first_name ASC, id DESC`.\n\nNote that `id` can always be used for sorting regardless of whether you whitelist it or not. Any non whitelisted sorting keys will be ignored.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/umar221b/arrangeable.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumar221b%2Farrangeable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fumar221b%2Farrangeable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fumar221b%2Farrangeable/lists"}