{"id":13879924,"url":"https://github.com/krisleech/not_found","last_synced_at":"2025-10-27T18:03:36.089Z","repository":{"id":56885765,"uuid":"46148091","full_name":"krisleech/not_found","owner":"krisleech","description":"Allows you to rescue ActiveRecord::RecordNotFound for a specific model","archived":false,"fork":false,"pushed_at":"2015-11-23T16:20:38.000Z","size":13,"stargazers_count":60,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-25T04:43:43.521Z","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/krisleech.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":"2015-11-13T21:26:23.000Z","updated_at":"2020-07-27T02:20:53.000Z","dependencies_parsed_at":"2022-08-21T00:20:40.651Z","dependency_job_id":null,"html_url":"https://github.com/krisleech/not_found","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/krisleech/not_found","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fnot_found","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fnot_found/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fnot_found/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fnot_found/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krisleech","download_url":"https://codeload.github.com/krisleech/not_found/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krisleech%2Fnot_found/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281314608,"owners_count":26480007,"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-10-27T02:00:05.855Z","response_time":61,"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":[],"created_at":"2024-08-06T08:02:39.286Z","updated_at":"2025-10-27T18:03:36.074Z","avatar_url":"https://github.com/krisleech.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# NotFound (alpha)\n\n[![Gem Version](https://badge.fury.io/rb/not_found.png)](http://badge.fury.io/rb/not_found)\n[![Code Climate](https://codeclimate.com/github/krisleech/not_found.png)](https://codeclimate.com/github/krisleech/not_found)\n[![Build Status](https://travis-ci.org/krisleech/not_found.png?branch=master)](https://travis-ci.org/krisleech/not_found)\n[![Coverage Status](https://coveralls.io/repos/krisleech/not_found/badge.png?branch=master)](https://coveralls.io/r/krisleech/not_found?branch=master)\n\nAllows you to rescue `ActiveRecord::RecordNotFound` for a specific model.\n\nFor example if you have a `User` model you can rescue `User::RecordNotFound`.\n\nCode which rescue `ActiveRecord::Record` will still work as expected.\n\n## Why?\n\nBecause a rescue block around code which rescues `ActiveRecord::RecordNotFound`\nmight work as expected today, but some time in the future when within that\nblock another model ends up raising `ActiveRecord::RecordNotFound` it leads to\nunexpected behaviour which is diffcult to trace. This gem allows you to be\nexplicit about what you want to rescue.\n\n## Installation\n\n```ruby\ngem 'not_found'\n```\n\n## Usage\n\nInclude the mixin for a single model\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  include NotFound::Mixin\nend\n```\n\nor every model\n\n```ruby\nActiveRecord::Base.class_eval { include NotFound::Mixin }\n```\n\nand rescue away like this\n\n```ruby\nbegin\n  user = User.find(id)\nrescue User::RecordNotFound\n  # handle missing user\nend\n```\n\nor this\n\n```ruby\nbegin\n  user = User.find(id)\n  post = Post.find(id)\nrescue User::RecordNotFound\n  # handle missing user\nrescue Post::RecordNotFound\n  # handle missing post\nend\n```\n\nor this\n\n```ruby\nbegin\n  user = User.find(id)\n  post = Post.find(id)\nrescue User::RecordNotFound\n  # handle missing user\nrescue ActiveRecord::RecordNotFound\n  # handle missing posts and other models\nend\n```\n\n## Compatibility\n\nTested with MRI 2.x, JRuby and Rubinius.\n\nSee the [build status](https://travis-ci.org/krisleech/not_found) for details.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.\nYou 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`.\nTo 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### Running Specs\n\n```\nbundle exec rspec\n```\n\nTo run the specs on code changes try [entr](http://entrproject.org/):\n\n```\nls **/*.rb | entr bundle exec rspec\n```\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/krisleech/not_found. \nThis project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fnot_found","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrisleech%2Fnot_found","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrisleech%2Fnot_found/lists"}