{"id":15350135,"url":"https://github.com/mars/typical_situation","last_synced_at":"2025-07-16T01:40:57.948Z","repository":{"id":7585745,"uuid":"8941565","full_name":"mars/typical_situation","owner":"mars","description":"The missing Ruby on Rails ActionController REST API mixin.","archived":false,"fork":false,"pushed_at":"2019-11-18T20:03:24.000Z","size":212,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T19:18:19.786Z","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/mars.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2013-03-22T00:18:01.000Z","updated_at":"2014-08-14T20:14:10.000Z","dependencies_parsed_at":"2022-08-30T07:01:22.662Z","dependency_job_id":null,"html_url":"https://github.com/mars/typical_situation","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Ftypical_situation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Ftypical_situation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Ftypical_situation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mars%2Ftypical_situation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mars","download_url":"https://codeload.github.com/mars/typical_situation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247142075,"owners_count":20890653,"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-01T11:57:37.874Z","updated_at":"2025-04-04T08:13:38.092Z","avatar_url":"https://github.com/mars.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Typical Situation [![Build Status](https://travis-ci.org/mars/typical_situation.png)](https://travis-ci.org/mars/typical_situation)\n\nThe missing Ruby on Rails ActionController REST API mixin.\n\nA Ruby mixin (module) providing the seven standard resource actions \u0026 responses for an ActiveRecord :model_type \u0026 :collection.\n\n## Installation\n\nRequires (tested in) **Rails 3.2** \u0026 **Ruby 1.9**.\n\nAdd to your **Gemfile**:\n\n    gem 'typical_situation', github: 'mars/typical_situation'\n\n## Usage\n\n### Define three methods\n\n    class MockApplePiesController \u003c ApplicationController\n      include TypicalSituation\n\n      # Symbolized, underscored version of the model (class) to use as the resource.\n      def model_type\n        :mock_apple_pie\n      end\n      \n      # The collection of model instances.\n      def collection\n        current_user.mock_apple_pies\n      end\n      \n      # Find a model instance by ID. \n      def find_in_collection(id)\n        collection.find_by_id(id)\n      end\n    end\n\n### Get a fully functional REST API\n\nThe seven standard resourceful actions:\n\n  1. **index**\n  1. **show**\n  1. **new**\n  1. **create**\n  1. **edit**\n  1. **update**\n  1. **delete**\n\nFor the content types:\n\n  * **HTML**\n  * **JSON**\n\nWith response handling for:\n\n  * the collection\n  * a single instance\n  * not found\n  * validation errors (using ActiveModel::Errors format)\n  * changed\n  * deleted/gone\n\n### Customize by overriding highly composable methods\n\n**TypicalSituation** is composed of a library of common functionality, which can all be overridden in individual controllers. Express what is *different* \u0026 *special* about each controller, instead of repeating boilerplate.\n\nThe library is split into modules:\n\n  * [identity](https://github.com/mars/typical_situation/blob/master/lib/typical_situation/identity.rb) - **required definitions** of the model \u0026 how to find it\n  * [actions](https://github.com/mars/typical_situation/blob/master/lib/typical_situation/actions.rb) - high-level controller actions\n  * [operations](https://github.com/mars/typical_situation/blob/master/lib/typical_situation/operations.rb) - loading, changing, \u0026 persisting the model\n  * [responses](https://github.com/mars/typical_situation/blob/master/lib/typical_situation/responses.rb) - HTTP responses \u0026 redirects\n\n## Legalese\n\nThis project uses MIT-LICENSE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmars%2Ftypical_situation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmars%2Ftypical_situation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmars%2Ftypical_situation/lists"}