{"id":9478,"date":"2020-04-01T12:29:38","date_gmt":"2020-04-01T06:59:38","guid":{"rendered":"https:\/\/www.botreetechnologies.com\/blog\/?p=9478"},"modified":"2020-12-04T17:02:30","modified_gmt":"2020-12-04T11:32:30","slug":"how-to-install-and-use-mongodb-with-rails6","status":"publish","type":"post","link":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/","title":{"rendered":"Installation and Usage of Rails MongoDB"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Rails MongoDB : Introduction<\/h2>\n\n\n\n<p><strong>MongoDB is a document database with the scalability, flexibility and the querying and indexing of the records.<\/strong><\/p>\n\n\n\n<p>In this blog, we will cover how to install it in Ubuntu 16.04, configure and use it with <a href=\"https:\/\/www.botreetechnologies.com\/ruby-on-rails-development\">Rails 6 application<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Install MongoDB with Rails in Ubuntu 16.04 LTS<\/h2>\n\n\n\n<p>The steps are for Ubuntu 16.04 but you can install in other versions as well.<\/p>\n\n\n\n<p>Follow below steps in your terminal to install it from the source.<\/p>\n\n\n\n<p><code>sudo apt-key adv --keyserver hkp:\/\/keyserver.ubuntu.com:80 --recv EA312927<\/code><\/p>\n\n\n\n<p><code>echo \"deb http:\/\/repo.mongodb.org\/apt\/ubuntu xenial\/mongodb-org\/3.2 multiverse\" | sudo tee \/etc\/apt\/sources.list.d\/mongodb-org-3.2.list<\/code><\/p>\n\n\n\n<p>After adding this repo update the packages<\/p>\n\n\n\n<p><code>sudo apt-get update<\/code><\/p>\n\n\n\n<p>Now, install mongo db using below command<\/p>\n\n\n\n<p><code>sudo apt-get install -y mongodb-org<\/code><\/p>\n\n\n\n<p>If you face any issue like below<\/p>\n\n\n\n<p><code>WARNING: The following packages cannot be authenticated!<\/code><\/p>\n\n\n\n<p><code>mongodb-org-shell mongodb-org-server mongodb-org-mongos mongodb-org-tools mongodb-org<\/code><\/p>\n\n\n\n<p><code>E:There were unauthenticated packages and -y was used without --allow-unauthenticated<\/code><\/p>\n\n\n\n<p>Then install it using the below command. Please note the risk of overriding the authentication warning here.<\/p>\n\n\n\n<p><code>sudo apt-get --allow-unauthenticated install -y mongodb-org<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Configuration and Starting the Services<\/h2>\n\n\n\n<p>After you are done with the installation, configure and start the service using below commands in your terminal<\/p>\n\n\n\n<p><code>sudo systemctl start mongod<\/code><\/p>\n\n\n\n<p>Check if the service has properly started or not using below command<\/p>\n\n\n\n<p><code>sudo systemctl status mongod<\/code><\/p>\n\n\n\n<p>Using below command you can start it automatically when your system starts<\/p>\n\n\n\n<p><code>sudo systemctl enable mongod<\/code><\/p>\n\n\n\n<p>Now, MongoDB is set up and services are running. Let\u2019s see how to use it with Rails 6<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>Read Also: <a href=\"https:\/\/www.botreetechnologies.com\/blog\/notable-activerecord-changes-in-rails-6-part-3\" target=\"_blank\" rel=\"noopener noreferrer\">Notable ActiveRecord Changes in Rails 6<\/a><\/p><\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">3. <strong>MongoDB <\/strong>Setup<strong>&nbsp;<\/strong>with Rails 6<\/h2>\n\n\n\n<p>Create a new rails application using below command:<\/p>\n\n\n\n<p><code>rails new mongorails --skip-active-record --skip-bundle<\/code><\/p>\n\n\n\n<p>We have used <code>--skip-active-record<\/code> dependencies as we are not using it. We also used&nbsp; <code>--skip-bundle<\/code> to skip gem installations as we need to change the gemfile to add MongoDB dependency.<\/p>\n\n\n\n<p>If you are going to to use RSpec for testing then you can create your application using below command by skipping the default testing framework of rails<\/p>\n\n\n\n<p><code>rails new mongorails --skip-active-record --skip-bundle --skip-test --skip-system-test<\/code><\/p>\n\n\n\n<p>Now, go to your project directory and add <a href=\"https:\/\/github.com\/mongodb\/mongoid\/\" target=\"_blank\" rel=\"noopener noreferrer\">mongoid<\/a> gem in Gemfile. Mongoid is the officially supported ODM (Object-Document-Mapper) framework for MongoDB in Ruby.<\/p>\n\n\n\n<p><code>gem 'mongoid', '~&gt; 7.0.5'<\/code><\/p>\n\n\n\n<p>NOTE:&nbsp; Mongoid 7.0.5 or higher is required to use Rails 6.0.<\/p>\n\n\n\n<p>Run below command to install the gem<\/p>\n\n\n\n<p><code>bundle install<\/code><\/p>\n\n\n\n<p>Run below command to generate a default configuration<\/p>\n\n\n\n<p><code>bin\/rails g mongoid:config<\/code><\/p>\n\n\n\n<p>This command would create a <code>mongoid.yml<\/code> file in <code>config<\/code> directory which is a replacement of <code>database.yml<\/code> which rails create by default for us.<\/p>\n\n\n\n<p>It is recommended to change <code>server_selection_timeout<\/code><\/p>\n\n\n\n<p>from 30 seconds to 1 second for the development environment. You can change it in <code>mongoid.yml<\/code><\/p>\n\n\n\n<p>Now, start rails server to check if everything is set up and configured correctly<\/p>\n\n\n\n<p><code>rails s<\/code><\/p>\n\n\n\n<p>If you see below screen after visiting <code>localhost:3000<\/code>&nbsp; in your browser then everything is good so far.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-9489\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/rails6-mongodb.png\" alt=\"rails mongodb installation and usage\" width=\"480\" height=\"363\"><\/h2>\n\n\n\n<h2 class=\"wp-block-heading\">4. How to use <strong>MongoDB <\/strong>with Rails<\/h2>\n\n\n\n<p>Now, let&#8217;s create scaffolds using rails and check how the Model is working with MongoDB.<\/p>\n\n\n\n<p>We will create a small application where people can create posts and can comment on it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Creating Posts<\/h3>\n\n\n\n<p>Create a post using scaffolding. Yes, you can use scaffolding with <strong>MongoDB<\/strong> as well, and it would create all necessary files as it does for other databases.<\/p>\n\n\n\n<p><code>rails generate scaffold Post title:string body:text<\/code><\/p>\n\n\n\n<p>The important point to note is that we do not have a db folder and there is no need to run migrations.<\/p>\n\n\n\n<p>Post model will look like this<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/post-model.png\" alt=\"post model in mongodb ruby on rails\" class=\"wp-image-9481\"\/><\/figure>\n\n\n\n<p>Now, head to the browser and visit <code>localhost:3000\/posts<\/code> and you will see a list of posts and you can create\/update\/delete the posts. Same old rails stuff \ud83d\ude42<\/p>\n\n\n\n<p>Once you create the post it will fire insert query as below:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/insert-query.png\" alt=\"rails mongodb integration - insert query \" class=\"wp-image-9482\"\/><\/figure>\n\n\n\n<p>You can notice that it has first found the database name <code>mongorails_development.insert<\/code> and then used the below syntax to insert the record to the <code>posts<\/code> table.<\/p>\n\n\n\n<p><code>{\"insert\"=&gt;\"posts\", \"documents\"=&gt;[{\"_id\"=&gt;BSON::ObjectId('5e7d91f2d3527338a88a0751'), \"title\"=&gt;\"Shiny Post\", \"body\"=&gt;\"Lorem ipsum\"}], \"ordered\"=&gt;true}<\/code><\/p>\n\n\n\n<p>And when you visit show path of the app, it would fire below query<\/p>\n\n\n\n<p><code>mongorails_development.find | STARTED | {\"find\"=&gt;\"posts\", \"filter\"=&gt;{\"_id\"=&gt;BSON::ObjectId('5e7d91f2d3527338a88a0751')}}<\/code><\/p>\n\n\n\n<p>You can find the post from your rails console using below command<\/p>\n\n\n\n<p><code>Post.find('5e7d91f2d3527338a88a0751')<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Creating a comment<\/h3>\n\n\n\n<p>Let\u2019s create comments on the blogs<\/p>\n\n\n\n<p>Run below command to create comment and associate with posts using scaffold<\/p>\n\n\n\n<p><code>rails generate scaffold Comment name:string message:string post:belongs_to<\/code><\/p>\n\n\n\n<p>By default, it would generate comment model code as below.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/generate-comment-model-code.png\" alt=\"ruby on rails with mongodb\" class=\"wp-image-9483\"\/><\/figure><\/div>\n\n\n\n<p>Change <code>embedded_in :post<\/code> to <code>belongs_to :post<\/code><\/p>\n\n\n\n<p>Open <code>comments\/_form<\/code> and change the type of field for <code>:message<\/code> from <code>text_field to text_area<\/code>, as well as the type of field for <code>:post_id<\/code> from text_field to hidden_field<\/p>\n\n\n\n<p>Add below code in <code>posts\/show.html.erb<\/code> to create comments for the post. This will list all the comments for the post and also allow you to add new comments.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/add-new-comments.png\" alt=\"ruby on rails mongodb\" class=\"wp-image-9484\"\/><\/figure>\n\n\n\n<p>Now, create <code>_comment.html.erb partial<\/code> in <code>app\/views\/comments<code> folder with the code below:<\/code><\/code><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/12\/folder-with-the-code-1.png\" alt=\"mongodb rails\" class=\"wp-image-9486\"\/><\/figure>\n\n\n\n<p>If you want to add a new field to the table just add it using the below line. I have added a new field to posts table using below line<\/p>\n\n\n\n<p><code>field :slug, type: String<\/code><\/p>\n\n\n\n<p>It is that simple!!<\/p>\n\n\n\n<p>You don\u2019t need to declare a foreign key field to comment on the model. It would implicitly create the <code>post_id<\/code> to comments table. The naming convention for a foreign key is the same as active records.<\/p>\n\n\n\n<p>That&#8217;s it, You have created a small application using MongoDB.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/www.botreetechnologies.com\/ruby-on-rails-development\"><b>Click here for more<\/b> details&#8230;<\/a><\/h3>\n\n\n\n<p>At <a href=\"https:\/\/www.botreetechnologies.com\/\">BoTree Technologies<\/a>, we build enterprise applications with our RoR team of 25+ engineers.<\/p>\n\n\n\n<p>We also specialize in Python, RPA, AI, Django, JavaScript and ReactJS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/www.botreetechnologies.com\/contact\">Consulting is free<\/a> &#8211; let us help you grow!<\/h3>\n","protected":false},"excerpt":{"rendered":"<p>Rails MongoDB : Introduction MongoDB is a document database with&#8230;<\/p>\n","protected":false},"author":8,"featured_media":13258,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73,10],"tags":[],"class_list":["post-9478","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby-on-rails","category-technology"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Installation and Usage of Rails MongoDB<\/title>\n<meta name=\"description\" content=\"Want to learn how to install and use MongoDB with Rails 6 to build interactive apps? Here\u2019s a complete guide on how to utilize rails MongoDB for app creation with Rails 6 in Ubuntu 16.04.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Installation and Usage of Rails MongoDB\" \/>\n<meta property=\"og:description\" content=\"Want to learn how to install and use MongoDB with Rails 6 to build interactive apps? Here\u2019s a complete guide on how to utilize rails MongoDB for app creation with Rails 6 in Ubuntu 16.04.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/\" \/>\n<meta property=\"og:site_name\" content=\"BoTree Technologies\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/BoTreeTechnologies\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-01T06:59:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-12-04T11:32:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/04\/how-to-install-and-use-mongodb-with-rails-6-1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1280\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sanjay Prajapati\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:site\" content=\"@BoTreeTech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sanjay Prajapati\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/\"},\"author\":{\"name\":\"Sanjay Prajapati\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/b628623fa9d946d2258f506a476b45e3\"},\"headline\":\"Installation and Usage of Rails MongoDB\",\"datePublished\":\"2020-04-01T06:59:38+00:00\",\"dateModified\":\"2020-12-04T11:32:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/\"},\"wordCount\":765,\"commentCount\":10,\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/04\/how-to-install-and-use-mongodb-with-rails-6-1.jpg\",\"articleSection\":[\"Ruby on Rails\",\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/\",\"name\":\"Installation and Usage of Rails MongoDB\",\"isPartOf\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/04\/how-to-install-and-use-mongodb-with-rails-6-1.jpg\",\"datePublished\":\"2020-04-01T06:59:38+00:00\",\"dateModified\":\"2020-12-04T11:32:30+00:00\",\"author\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/b628623fa9d946d2258f506a476b45e3\"},\"description\":\"Want to learn how to install and use MongoDB with Rails 6 to build interactive apps? Here\u2019s a complete guide on how to utilize rails MongoDB for app creation with Rails 6 in Ubuntu 16.04.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#primaryimage\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/04\/how-to-install-and-use-mongodb-with-rails-6-1.jpg\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/04\/how-to-install-and-use-mongodb-with-rails-6-1.jpg\",\"width\":1920,\"height\":1280,\"caption\":\"How to Install MongoDB on Ubuntu 16.04 LTS\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.botreetechnologies.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Installation and Usage of Rails MongoDB\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#website\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/\",\"name\":\"BoTree Technologies\",\"description\":\"Committed to inspire generation.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/b628623fa9d946d2258f506a476b45e3\",\"name\":\"Sanjay Prajapati\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/sanjay-prajapati-150x150.png\",\"url\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/sanjay-prajapati-150x150.png\",\"contentUrl\":\"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/sanjay-prajapati-150x150.png\",\"caption\":\"Sanjay Prajapati\"},\"description\":\"Sanjay is a Ruby on Rails Engineer, who also works with Javascript and React. He has strong experience in working with domains like eCommerce, Health and Insurance. In his spare time, he enjoys reading and writing blogs and he is excited to help add the company to his list of successes.\u200b\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Installation and Usage of Rails MongoDB","description":"Want to learn how to install and use MongoDB with Rails 6 to build interactive apps? Here\u2019s a complete guide on how to utilize rails MongoDB for app creation with Rails 6 in Ubuntu 16.04.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/","og_locale":"en_US","og_type":"article","og_title":"Installation and Usage of Rails MongoDB","og_description":"Want to learn how to install and use MongoDB with Rails 6 to build interactive apps? Here\u2019s a complete guide on how to utilize rails MongoDB for app creation with Rails 6 in Ubuntu 16.04.","og_url":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/","og_site_name":"BoTree Technologies","article_publisher":"https:\/\/www.facebook.com\/BoTreeTechnologies\/","article_published_time":"2020-04-01T06:59:38+00:00","article_modified_time":"2020-12-04T11:32:30+00:00","og_image":[{"width":1920,"height":1280,"url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/04\/how-to-install-and-use-mongodb-with-rails-6-1.jpg","type":"image\/jpeg"}],"author":"Sanjay Prajapati","twitter_card":"summary_large_image","twitter_creator":"@BoTreeTech","twitter_site":"@BoTreeTech","twitter_misc":{"Written by":"Sanjay Prajapati","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#article","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/"},"author":{"name":"Sanjay Prajapati","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/b628623fa9d946d2258f506a476b45e3"},"headline":"Installation and Usage of Rails MongoDB","datePublished":"2020-04-01T06:59:38+00:00","dateModified":"2020-12-04T11:32:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/"},"wordCount":765,"commentCount":10,"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/04\/how-to-install-and-use-mongodb-with-rails-6-1.jpg","articleSection":["Ruby on Rails","Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/","url":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/","name":"Installation and Usage of Rails MongoDB","isPartOf":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#primaryimage"},"image":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#primaryimage"},"thumbnailUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/04\/how-to-install-and-use-mongodb-with-rails-6-1.jpg","datePublished":"2020-04-01T06:59:38+00:00","dateModified":"2020-12-04T11:32:30+00:00","author":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/b628623fa9d946d2258f506a476b45e3"},"description":"Want to learn how to install and use MongoDB with Rails 6 to build interactive apps? Here\u2019s a complete guide on how to utilize rails MongoDB for app creation with Rails 6 in Ubuntu 16.04.","breadcrumb":{"@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#primaryimage","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/04\/how-to-install-and-use-mongodb-with-rails-6-1.jpg","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/04\/how-to-install-and-use-mongodb-with-rails-6-1.jpg","width":1920,"height":1280,"caption":"How to Install MongoDB on Ubuntu 16.04 LTS"},{"@type":"BreadcrumbList","@id":"https:\/\/www.botreetechnologies.com\/blog\/how-to-install-and-use-mongodb-with-rails6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.botreetechnologies.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Installation and Usage of Rails MongoDB"}]},{"@type":"WebSite","@id":"https:\/\/www.botreetechnologies.com\/blog\/#website","url":"https:\/\/www.botreetechnologies.com\/blog\/","name":"BoTree Technologies","description":"Committed to inspire generation.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.botreetechnologies.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.botreetechnologies.com\/blog\/#\/schema\/person\/b628623fa9d946d2258f506a476b45e3","name":"Sanjay Prajapati","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/sanjay-prajapati-150x150.png","url":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/sanjay-prajapati-150x150.png","contentUrl":"https:\/\/www.botreetechnologies.com\/blog\/wp-content\/uploads\/2020\/10\/sanjay-prajapati-150x150.png","caption":"Sanjay Prajapati"},"description":"Sanjay is a Ruby on Rails Engineer, who also works with Javascript and React. He has strong experience in working with domains like eCommerce, Health and Insurance. In his spare time, he enjoys reading and writing blogs and he is excited to help add the company to his list of successes.\u200b"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/9478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/comments?post=9478"}],"version-history":[{"count":2,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/9478\/revisions"}],"predecessor-version":[{"id":13298,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/posts\/9478\/revisions\/13298"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media\/13258"}],"wp:attachment":[{"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/media?parent=9478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/categories?post=9478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.botreetechnologies.com\/blog\/wp-json\/wp\/v2\/tags?post=9478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}