{"id":15554170,"url":"https://github.com/cimon-io/unobtrusive_resources","last_synced_at":"2025-05-07T13:04:42.662Z","repository":{"id":59158687,"uuid":"129618130","full_name":"cimon-io/unobtrusive_resources","owner":"cimon-io","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-18T16:52:56.000Z","size":23,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-07T13:04:34.094Z","etag":null,"topics":["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/cimon-io.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":"2018-04-15T14:28:10.000Z","updated_at":"2025-04-18T16:53:00.000Z","dependencies_parsed_at":"2022-09-13T20:10:21.020Z","dependency_job_id":null,"html_url":"https://github.com/cimon-io/unobtrusive_resources","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/cimon-io%2Funobtrusive_resources","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cimon-io%2Funobtrusive_resources/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cimon-io%2Funobtrusive_resources/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cimon-io%2Funobtrusive_resources/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cimon-io","download_url":"https://codeload.github.com/cimon-io/unobtrusive_resources/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252883226,"owners_count":21819158,"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":["ruby","ruby-on-rails"],"created_at":"2024-10-02T14:51:06.083Z","updated_at":"2025-05-07T13:04:42.641Z","avatar_url":"https://github.com/cimon-io.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UnobtrusiveResources\n\nThis gem provides convenient set of methods for resource management to keep your controllers as \"skinny\" as possible.\nMain idea is to organize controller actions' code in terms of resource CRUD.\n\nExample:\n\n```ruby\nclass BotsController \u003c ApplicationController\n  # ...\n\n  unobtrusive finder_method: :find_by_slug!,\n              find_for_create_by: :slug,\n              resource_class: Bot,\n              relationship_name: :bots,\n              permitted_params_key: :bot,\n              permitted_params_create_value: %i[name code],\n              permitted_params_update_value: %i[name code]\n  def index\n    respond_with(collection)\n  end\n\n  def show\n    respond_with(resource)\n  end\n\n  def new\n    build_resource\n    respond_with(resource)\n  end\n\n  def create\n    find_or_create_resource\n    respond_with(resource)\n  end\n\n  def update\n    update_resource\n    respond_with(resource)\n  end\n\n  def destroy\n    destroy_resource\n    respond_with(resource)\n  end\n  # ...\nend\n```\n\nKeep in mind, that following methods should be defined (or configured with `unobtrusive` method call) in order to make default configuration to work properly:\n\n  - `relationship_name`\n  - `resource_class`\n  - `find_for_create_by`\n  - `permitted_params_key`\n  - `permitted_params_create_value`\n  - `permitted_params_update_value`\n  - `parent_class`\n  - `parent_permitted_params_key`\n\nFor real-life projects most resource related actions will be a bit more complicated.\nIn such cases we can easily change underlying logic for, say, resource creation (redefine method):\n\n```ruby\nclass BotsController \u003c ApplicationController\n  # ...\n\n  private\n\n  # Here `Bot` may be some model class or service object.\n  def create_resource\n    @_resource = Bot.custom_create(permitted_params)\n  end\n  # ...\nend\n```\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'unobtrusive_resources'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install unobtrusive_resources\n\n## Usage\n\nThere is no need for additional initializer.\nAll necessary methods will be included into `ActionController::Base` via `ActiveSupport.on_load` (lazy load hook).\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You 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`. To 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## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/cimon-io/unobtrusive_resources. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the UnobtrusiveResources project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/cimon-io/unobtrusive_resources/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcimon-io%2Funobtrusive_resources","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcimon-io%2Funobtrusive_resources","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcimon-io%2Funobtrusive_resources/lists"}