{"id":28219902,"url":"https://github.com/phoffer/hanami-activerecord","last_synced_at":"2026-04-30T14:31:50.722Z","repository":{"id":71365819,"uuid":"93907552","full_name":"phoffer/hanami-activerecord","owner":"phoffer","description":"Use ActiveRecord with Hanami. Not encouraged, but occasionally necessary.","archived":false,"fork":false,"pushed_at":"2017-06-10T01:09:00.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-11T09:48:02.458Z","etag":null,"topics":["activerecord","bad-idea","hanami"],"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/phoffer.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-06-10T01:04:13.000Z","updated_at":"2017-12-25T23:11:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"245fd877-f3c4-47f3-8b1f-38f3c8a4968d","html_url":"https://github.com/phoffer/hanami-activerecord","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phoffer/hanami-activerecord","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoffer%2Fhanami-activerecord","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoffer%2Fhanami-activerecord/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoffer%2Fhanami-activerecord/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoffer%2Fhanami-activerecord/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phoffer","download_url":"https://codeload.github.com/phoffer/hanami-activerecord/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phoffer%2Fhanami-activerecord/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32468009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["activerecord","bad-idea","hanami"],"created_at":"2025-05-18T03:11:45.390Z","updated_at":"2026-04-30T14:31:50.717Z","avatar_url":"https://github.com/phoffer.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hanami with ActiveRecord\n\nThis is how to use ActiveRecord with Hanami. While this is not advised, you may find yourself in a situation in which you need AR. For me, this was needing to use PostGIS, which I had trouble configuring for Hanami-model.\n\n## Setup\n\nIt is pretty simple to ActiveRecord working with Hanami.\n\n1. Create application\n1. Change configuration\n1. Setup db\n\nGenerate the app as you normally would. This example uses Postgres, but it shouldn't matter.\n\nAll the changes necessary (including new files) are in commit [20684f4](https://github.com/phoffer/hanami-activerecord/commit/20684f41883df7857158ad38df709c052742a1fe). A sample test was added in [6bdd1d4](https://github.com/phoffer/hanami-activerecord/commit/6bdd1d4d8dffd4fcff51f7bffcc184954ec76503). \n\nSlightly modified steps from Hanami's [Bring Your Own ORM guide](http://hanamirb.org/guides/models/use-your-own-orm/):\n\n* Edit your `Gemfile`, remove `hanami-model`, add the gem(s) of your ORM and run `bundle install`.\n  - I just changed `hanami-model` to `activerecord`.\n* Remove `lib/` directory (eg. `rm -rf lib`).\n  - *I did not remove the lib directory, as I will want to use it. I will also keep the `entities` directory, and put my AR models there.*\n* Edit `config/environment.rb`, then remove `require_relative '../lib/bookshelf`' and `model` block in `Hanami.configure`\n  *First make both suggested changes.\n  - Add `require 'active_record` to the environment file, and also the code to load ActiveRecord (see [config/environment.rb](https://github.com/phoffer/hanami-activerecord/blob/master/config/environment.rb))\n* Edit `Rakefile` and remove `require 'hanami/rake_tasks'`.\n  - Additionally, added code at bottom to add ActiveRecord rake tasks.\n\nI also added a few files, which are listed below.\n\n## New files to create\n\n* config/database.yml\n* db/seeds.rb\n* entities/application_record.rb\n* entities/user.rb\n\n## Commands to run\n\n```\nrk db:create\nrk db:new_migration name=CreateUsers options=\"email:string\"\nrk db:migrate RACK_ENV=test\nrk db:migrate\nrk db:seed\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphoffer%2Fhanami-activerecord","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphoffer%2Fhanami-activerecord","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphoffer%2Fhanami-activerecord/lists"}