{"id":16927806,"url":"https://github.com/indirect/simple_presenter","last_synced_at":"2025-04-11T17:43:20.617Z","repository":{"id":511942,"uuid":"139709","full_name":"indirect/simple_presenter","owner":"indirect","description":"presenter layer for rails","archived":false,"fork":false,"pushed_at":"2020-06-27T06:53:56.000Z","size":15,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-25T13:46:00.040Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/indirect.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2009-02-28T07:43:53.000Z","updated_at":"2019-08-13T14:04:50.000Z","dependencies_parsed_at":"2022-07-07T16:27:54.854Z","dependency_job_id":null,"html_url":"https://github.com/indirect/simple_presenter","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/indirect%2Fsimple_presenter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indirect%2Fsimple_presenter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indirect%2Fsimple_presenter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indirect%2Fsimple_presenter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indirect","download_url":"https://codeload.github.com/indirect/simple_presenter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248451835,"owners_count":21105950,"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-13T20:35:09.856Z","updated_at":"2025-04-11T17:43:20.598Z","avatar_url":"https://github.com/indirect.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"SimplePresenter\n===============\n\nSo code that generates format-specific representations of data is supposedly a View. In Rails, that code is sometimes inexplicably inserted into the Model, which is supposed to know nothing about formats or presentations of the data they represent.\n\nSimplePresenter is inspired by [simply\\_presentable](http://simply_presentable.richcollins.net), which is an implementation of the [Presentation Model](http://martinfowler.com/eaaDev/PresentationModel.html). There are [many](http://blog.jayfields.com/2007/03/rails-presenter-pattern.html) [other](http://gilesbowkett.blogspot.com/2007/10/my-version-of-rails-presenters.html) [presenter](http://jamesgolick.com/2008/7/28/introducing-activepresenter-the-presenter-library-you-already-know) libraries for Rails, but they are all based on the [Supervising Controller](http://martinfowler.com/eaaDev/SupervisingPresenter.html) pattern, so I had to write my own. SimplePresenter is just an easy way to get all that view code out of your model and into a separate (and testable) file, without requiring you to write two pages of ruby code inside a single erb tag. Models with view code in them make Martin Fowler cry. Don't make Martin Fowler cry. Use SimplePresenter.\n\nUsage\n=====\n\nIn `app/presenter/foo_presenter.rb`:\n\n    class FooPresenter \u003c SimplePresenter\n      def to_json\n        {:id =\u003e id, :name =\u003e name}.to_json\n      end\n    end\n\nIn `app/controller/foo_controller.rb`:\n\n    class FooController \u003c ApplicationController\n      def show\n        @foo = Foo.find(params[:id])\n        render :json =\u003e present(@foo)\n      end\n    end\n\n`render :json =\u003e foo` implicitly calls to\\_json on `foo`.\n\nhttp://github.com/indirect/simple_presenter\n\nCopyright (c) 2009 Andre Arko, released under the MIT license","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findirect%2Fsimple_presenter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findirect%2Fsimple_presenter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findirect%2Fsimple_presenter/lists"}