{"id":14956604,"url":"https://github.com/mongodb/mongoid-railsmdb","last_synced_at":"2025-11-11T18:40:40.524Z","repository":{"id":184040206,"uuid":"671090112","full_name":"mongodb/mongoid-railsmdb","owner":"mongodb","description":"A command-line tool like the Rails CLI for creating, managing, and maintaining a Mongoid/Rails app.","archived":false,"fork":false,"pushed_at":"2025-04-11T08:39:09.000Z","size":80,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-19T17:54:51.273Z","etag":null,"topics":["cli","mongodb","mongoid","odm","orm","ruby-on-rails"],"latest_commit_sha":null,"homepage":"https://www.mongodb.com/docs/mongoid","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/mongodb.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":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-07-26T14:12:36.000Z","updated_at":"2025-04-11T08:39:06.000Z","dependencies_parsed_at":"2023-07-26T21:22:59.665Z","dependency_job_id":"a3857173-a12f-48e4-8143-221b45cff708","html_url":"https://github.com/mongodb/mongoid-railsmdb","commit_stats":{"total_commits":30,"total_committers":3,"mean_commits":10.0,"dds":0.06666666666666665,"last_synced_commit":"78bcd03c8acd59918ae872a84377ebd70180212f"},"previous_names":["mongodb/mongoid-railsmdb"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/mongodb/mongoid-railsmdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongoid-railsmdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongoid-railsmdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongoid-railsmdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongoid-railsmdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongodb","download_url":"https://codeload.github.com/mongodb/mongoid-railsmdb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongoid-railsmdb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":283910127,"owners_count":26915128,"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","status":"online","status_checked_at":"2025-11-11T02:00:06.610Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cli","mongodb","mongoid","odm","orm","ruby-on-rails"],"created_at":"2024-09-24T13:13:12.007Z","updated_at":"2025-11-11T18:40:40.507Z","avatar_url":"https://github.com/mongodb.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Railsmdb for Mongoid\n\nRailsmdb is a command-line utility for creating, updating, managing,\nand maintaining Rails applications that use Mongoid and MongoDB for data storage. It is an extension of (and supports all other functionality of) the `rails` command from Ruby on Rails.\n\n\n## Installation\n\n\u003e [!NOTE]  \n\u003e Note that until Railsmdb 1.0.0 final is released the `--pre` flag will be required for installation\n\u003e \nTo install Railsmdb:\n\n```\n$ gem install railsmdb --pre\n```\n\nThis will install a new command, `railsmdb`.\n\n## Usage\n\nThe `railsmdb` command may be invoked exactly as you would invoke the `rails` command. For example, to create a new Rails app:\n\n```\n$ railsmdb new my_new_rails_app\n```\n\nThis will create a new folder under the current directory called `my_new_rails_app`, and will populate it with all the scaffolding necessary to begin building your app.\n\nUnlike the `rails` command, however, it will set up the necessary gems and configuration for you to begin your Rails app using the MongoDB database, with Mongoid as the Object-Document Mapper (ODM).\n\nAlso, in your new application, there will be a new script in the `bin` folder: `bin/railsmdb`. You'll see `bin/rails` in there as well, but it now links to `bin/railsmdb`.\n\nBy default, `railsmdb` will not include ActiveRecord in your new application. If you wish to use both Mongoid and ActiveRecord (to connect to MongoDB and a separate, relational database in the same application), you can pass `--no-skip-active-record`:\n\n```\n$ railsmdb new my_new_rails_app --no-skip-active-record\n```\n\nThis will set up your application to use both Mongoid, and sqlite3 (by default). To start with a different relational database instead, you can pass the `--database` option:\n\n```\n$ railsmdb new my_new_rails_app --no-skip-active-record --database=mysql\n```\n\nTo see a list of all available commands, simply type `railsmdb` without any arguments.\n\n```\n$ railsmdb\n\n# alternatively:\n$ railsmdb -h\n```\n\n\n### Setting up railsmdb and Mongoid in an established Rails app\n\nIf you want to add `railsmdb` to an existing (non-Mongoid) Rails app, and add Mongoid configuration as well, you can use `railsmdb setup`:\n\n```\n$ railsmdb setup\n```\n\nThis must be run from the root directory of a Rails project. It will replace `bin/rails` with `bin/railsmdb`, add the `mongoid.yml` configuration file and the `mongoid.rb` initializer, and add the necessary gem entries to the `Gemfile`.\n\n**Note:** it is recommended to run this command in a branch, so that you can easily experiment with the changes and roll them back if necessary.\n\n\n### Generating Mongoid models\n\nYou can use `railsmdb` to generate stubs for new Mongoid models. From within a project:\n\n```\n$ bin/railsmdb generate model person\n```\n\nThis will create a new model at `app/models/person.rb`:\n\n```ruby\nclass Person\n  include Mongoid::Document\n  include Mongoid::Timestamp\nend\n```\n\nYou can specify the fields of the model as well:\n\n```ruby\n# bin/railsmdb generate model person name:string birth:date\n\nclass Person\n  include Mongoid::Document\n  include Mongoid::Timestamp\n  field :name, type: String\n  field :birth, type: Date\nend\n```\n\nYou can instruct the generator to make the new model a subclass of another, by passing the `--parent` option:\n\n```ruby\n# bin/railsmdb generate model student --parent=person\n\nclass Student \u003c Person\n  include Mongoid::Timestamp\nend\n```\n\nAnd if you need to store your models in a different collection than can be inferred from the model name, you can specify `--collection`:\n\n```ruby\n# bin/railsmdb generate model course --collection=classes\n\nclass Course\n  include Mongoid::Document\n  include Mongoid::Timestamp\n  store_in collection: 'classes'\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fmongoid-railsmdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongodb%2Fmongoid-railsmdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fmongoid-railsmdb/lists"}