{"id":15288848,"url":"https://github.com/chrismaximin/model_error_messages","last_synced_at":"2025-03-24T05:42:55.191Z","repository":{"id":56884189,"uuid":"71917248","full_name":"chrismaximin/model_error_messages","owner":"chrismaximin","description":"Ruby gem providing Rails helper, which displays a HTML div with the errors attached to a model.","archived":false,"fork":false,"pushed_at":"2018-11-21T01:27:53.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T19:51:27.365Z","etag":null,"topics":["errors","gem","rails-helper","ruby","ruby-on-rails"],"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/chrismaximin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-25T16:33:27.000Z","updated_at":"2022-09-20T12:09:45.000Z","dependencies_parsed_at":"2022-08-20T23:40:23.963Z","dependency_job_id":null,"html_url":"https://github.com/chrismaximin/model_error_messages","commit_stats":null,"previous_names":["christophemaximin/model_error_messages"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismaximin%2Fmodel_error_messages","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismaximin%2Fmodel_error_messages/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismaximin%2Fmodel_error_messages/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chrismaximin%2Fmodel_error_messages/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chrismaximin","download_url":"https://codeload.github.com/chrismaximin/model_error_messages/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245217791,"owners_count":20579297,"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":["errors","gem","rails-helper","ruby","ruby-on-rails"],"created_at":"2024-09-30T15:53:23.111Z","updated_at":"2025-03-24T05:42:55.171Z","avatar_url":"https://github.com/chrismaximin.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Model Error Messages\n\n[![Build Status](https://secure.travis-ci.org/christophemaximin/model_error_messages.png)](https://travis-ci.org/christophemaximin/model_error_messages)\n[![Gem version](https://badge.fury.io/rb/model_error_messages.png)](https://rubygems.org/gems/model_error_messages)\n[![Code Climate](https://codeclimate.com/github/christophemaximin/model_error_messages/badges/gpa.svg)](https://codeclimate.com/github/christophemaximin/model_error_messages)\n\nA simple Rails helper which displays a HTML div with the validation errors attached to a model.\n\n## Install\n\n**Model Error Messages**'s installation is pretty standard, add the following line to your `Gemfile`, then run `bundle install`:\n\n```rb\ngem 'model_error_messages'\n```\n\n## What this gem does / How to use\n\nThis gem allows you to use a helper called `model_error_messages`.  \nBy default, the wrapper `div` has the [Bootstrap](http://getbootstrap.com)-friendly classes `alert alert-danger`.  \nIf you have a typical form, you would want to display `model_error_messages(@model)` next to it, which will render something like:\n\n```html\n\u003cdiv class=\"alert alert-danger article-error-messages\"\u003e\n  \u003cul\u003e\n    \u003cli\u003eTitle can't be blank\u003c/li\u003e\n    \u003cli\u003eYou must select an author\u003c/li\u003e\n  \u003c/ul\u003e\n\u003c/div\u003e\n```\n\n... or if there is only one error:\n\n```html\n\u003cdiv class=\"alert alert-danger article-error-messages\"\u003e\n  \u003cp\u003eTitle can't be blank\u003c/p\u003e\n\u003c/div\u003e\n```\n\nExample of integration:\n\n```erb\n\u003c%= model_error_messages(@article) %\u003e\n\n\u003c%= form_for @article do |f| %\u003e\n  \u003c!-- ... form fields ... --\u003e\n\u003c% end %\u003e\n```\n\n## What this gem doesn't do\n\n* Include any other dependencies\n* Influence the generation of errors\n* Inject or execute any code in your controllers and models\n* Do anything with the `flash` messages\n* Anything not listed in \"What this gem does\"\n\n## Optional configuration\n\nYou can change the default behavior of `model_error_messages` by:\n\n## Setting an initializer\n\nCreate a file `config/initializers/model_error_messages.rb` and replace one of the defaults:\n\n```rb\nModelErrorMessages.configure do |config|\n  # Multiple errors will rendered in a several \u003cli\u003e in a \u003cul\u003e, while one error will be rendered in a \u003cp\u003e\n  config.single_error_in_paragraph = true\n\n  # The following classes will be added in the main wrapper div.\n  config.classes = lambda do |model|\n    [\n      'alert',\n      'alert-danger',\n      model.class.model_name.param_key + '-error-messages'\n    ].join(' ')\n  end\n\n  # Note: you can pass a simple string to `config.classes`, example:\n  # config.classes = 'alert alert-danger'\n\n  # HTML that will be added before the list of errors.\n  config.prepend_html = String.new\n\n  # HTML that will be added after the list of errors.\n  config.append_html = String.new\nend\n```\n\n## Passing options when calling `model_error_messages`\n\nExamples:\n\n```erb\n\u003c%= model_error_messages(@article, single_error_in_paragraph: false) %\u003e\n```\n\n## Contributing\n\nDon't hesitate to send a pull request!\n\n## Testing\n\n```sh\n$ bundle install\n$ bundle exec rspec spec/\n```\n\n## License\n\nThis software is distributed under the MIT License. Copyright (c) 2016-2019, Christophe Maximin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismaximin%2Fmodel_error_messages","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchrismaximin%2Fmodel_error_messages","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchrismaximin%2Fmodel_error_messages/lists"}