{"id":3020,"date":"2020-04-24T08:53:36","date_gmt":"2020-04-24T08:53:36","guid":{"rendered":"http:\/\/the-codest.localhost\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/"},"modified":"2026-04-24T11:29:23","modified_gmt":"2026-04-24T11:29:23","slug":"a-simple-ruby-application-from-scratch-with-active-record","status":"publish","type":"post","link":"https:\/\/thecodest.co\/en\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/","title":{"rendered":"A Simple Ruby Application from Scratch with Active Record"},"content":{"rendered":"\n<p>I like working with <strong><a href=\"https:\/\/thecodest.co\/en\/blog\/ways-to-increase-your-rails-performance\/\">Rails<\/a><\/strong> because I can easily and quickly create an application that works and show it to the world or just my friends. However, there are types of applications that do not need such a large framework as <strong>Rails<\/strong> and all its functionalities.<\/p>\n\n\n\n<p>It may happen that our application needs only M (Model) out of the whole MVC pattern <a href=\"https:\/\/en.wikipedia.org\/wiki\/Model\u2013view\u2013controller\" rel=\"nofollow\">Model-Controller<\/a>. Is it worth starting a <a href=\"https:\/\/thecodest.co\/en\/dictionary\/why-do-projects-fail\/\">project<\/a> in <strong>Rails<\/strong> if we know that the V-C (View-Controller) part will not be needed?<\/p>\n\n\n\n<p>It\u2019s good to know that <b>Active Record <\/b>, Active Model, Action Pack and Action View, which are responsible for MVC, can be used independently outside <strong>Rails<\/strong>. This allows <a href=\"https:\/\/thecodest.co\/en\/blog\/why-us-companies-are-opting-for-polish-developers\/\">us<\/a> to create a simple <strong><a href=\"https:\/\/thecodest.co\/en\/blog\/hire-ror-developer\/\">Ruby<\/a> application<\/strong> that has a database connection and develop it without the unnecessary <a href=\"https:\/\/thecodest.co\/en\/dictionary\/what-is-code-refactoring\/\">code<\/a> and libraries that we would get in a package by running the rails new command.<\/p>\n\n\n\n<p>I have described step by step how to achieve this and you can find the whole code on GitHub. The link is at the bottom of this article.&nbsp;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Structure<\/h2>\n\n\n\n<p>To start our project, we don&#8217;t need much. Let&#8217;s start by creating a <code>Gemfile<\/code> where we add the gems we need to work on the application, along with the version of <strong>Ruby<\/strong> we will be using.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"> cat Gemfile\n\n# frozen_string_literal: true\n\nsource 'https:\/\/rubygems.org'\n\nruby '2.7.2'\n<\/code><\/pre>\n\n\n\n<p>An optional <code>README.md<\/code> file is to describe how our application works and how to continue working on it, both for ourselves and other developers who will want to develop the project with us in the future.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\">cat README.md\n\n# Application\n\nTO DO: Delete this and the text above, and describe your app<\/code><\/pre>\n\n\n\n<p><code>app<\/code> directory with <code>application.rb<\/code> file, which will be responsible for configuration and loading libraries and files we will be adding in our application. Remember to run <code>bundle install<\/code> to generate the <code>Gemfile.lock<\/code>. The structure of our application at this stage should look like this:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"><code> tree\n .\n \u251c\u2500\u2500 Gemfile\n \u251c\u2500\u2500 Gemfile.lock\n \u251c\u2500\u2500 README.md\n \u2514\u2500\u2500 app\n \u00a0\u00a0\u00a0\u00a0\u2514\u2500\u2500 application.rb<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Database<\/h2>\n\n\n\n<p>With such a structure prepared, we can consider which database engine to choose and configure. For this article, I chose PostgresQL, with which I have the most experience. It can also be <a href=\"https:\/\/thecodest.co\/en\/blog\/fintech-app-development-services-features-in-2026\/\">MySQL<\/a> or SQlite3, or any other engine working with <em>Active Record<\/em>. When choosing technology, it is good to be guided by the purpose of the application, what it will be used for and what its purpose will be.&nbsp;<\/p>\n\n\n\n<p>For a quick and simple database configuration, I used <a href=\"https:\/\/thecodest.co\/en\/dictionary\/docker-developer\/\">docker<\/a> and docker-compose. I don&#8217;t want to elaborate on the configuration of these tools, their pros and cons, but if you&#8217;ve never used docker before then I&#8217;d refer you to the official documentation for <a href=\"https:\/\/docs.docker.com\/get-docker\/\" rel=\"nofollow\">Docker <\/a> and <a href=\"https:\/\/docs.docker.com\/compose\/install\/\" rel=\"nofollow\">Docker Compose<\/a> for more information.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"># docker-compose.yml\n\nversion: '3.7'\nservices:\n\u00a0\u00a0postgresql:\n\u00a0\u00a0\u00a0\u00a0image: postgres:12.0-alpine\n\u00a0\u00a0\u00a0\u00a0ports:\n- 5432:5432\n\u00a0\u00a0\u00a0\u00a0environment:\n- PGDATA=\/postgresql\n- POSTGRESPASSWORD=postgres\n- POSTGRESUSER=postgres\n\u00a0\u00a0\u00a0\u00a0volumes:\n- db-volume:\/postgresql\nvolumes:\n\u00a0\u00a0db-volume:<\/code><\/pre>\n\n\n\n<p>We will also need to add to our <code>Gemfile<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"><code> gem 'pg'\n<\/code><\/code><\/pre>\n\n\n\n<p>and to our <code>application.rb<\/code> file<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"># app\/application.rb\n\nrequire 'pg'\n\nmodule Application\n\n\u00a0\u00a0class Error &lt; StandardError; end\n\n# Your code goes here...\n\nend<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Standalone Migrations, Rake<\/h2>\n\n\n\n<p>The next step in configuring our application is to add the <code>standalone_migrations<\/code> and <code>rake<\/code> gems, which will allow us to manage our migrations just like in Rails and gain access to rake db: commands.&nbsp;<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Update <code>Gemfile<\/code> with the necessary gems, and do a <code>bundle install<\/code><\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"># gem used in non-rails and non-ruby applications\n\ngem 'standalone_migrations'\n\n# standalone_migrations need rake to be able to create migrations and run them, as in Rails\n\ngem 'rake'\n\n# Gem needed to load environment variables\n\ngem 'dotenv'<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>Let&#8217;s add a <code>Rakefile<\/code> to our project in the root directory, where we will load <code>dotenv<\/code> and <code>standalone_migrations<\/code> that we added earlier&nbsp;<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"># frozen_string_literal: true\n\nrequire 'dotenv'\n\nDotenv.load\n\nrequire 'standalone_migrations'\n\nStandaloneMigrations::Tasks.load_tasks<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>With the <code>Rakefile<\/code> configured this way, we can check if our <code>rake<\/code> is working by using the <code>rake -T<\/code> command, which should return a list of available commands in our application.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/app\/uploads\/2024\/05\/ruby-sample-code.png\" alt=\"ruby app\" title=\"Ruby app\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Before <code>rake db:create<\/code>, we still need to have a configuration file in our project to connect to the Postgres instance. To do this, we need to create a db directory along with a <code>config.yml<\/code> file that should look like the one below:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"># db\/config.yml\n\ndefault: &amp;default\n\n  adapter: postgresql\n\n  encoding: unicode\n\n  pool: &lt;%= ENV.fetch('MAX_THREADS') { 5 } %>\n\n  database: &lt;%= ENV.fetch('DATABASE_NAME') %>\n\n  username: &lt;%= ENV.fetch('DATABASE_USER') %>\n\n  password: &lt;%= ENV.fetch('DATABASE_PASSWORD') %>\n\n  host: &lt;%= ENV.fetch('DATABASE_HOST') %>\n\n  port: &lt;%= ENV.fetch('DATABASE_PORT') %>\n\ndevelopment:\n\n  &lt;&lt;: *default\n\ntest:\n\n  &lt;&lt;: *default\n\nstaging:\n\n  &lt;&lt;: *default\n\nproduction:\n\n  &lt;&lt;: *default<\/code><\/pre>\n\n\n\n<p>As you can see, I used environment variables to configure the connection to our Postgres, where we will keep sensitive <a href=\"https:\/\/thecodest.co\/en\/blog\/app-data-collection-security-risks-value-and-types-explored\/\">data<\/a> that should not be in the repository. For this I used the previously added <code>gem dotenv<\/code>, which was also added in the <code>Rakefile<\/code> along with <code>standalone_migrations<\/code>. If we are using Git to manage version control of our application, let\u2019s remember to add a <code>.gitignore<\/code> file where we will disable the possibility of tracking the <code>.env<\/code> file from our project.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"> # .gitignore\n.env*\n!.env.example<\/code><\/pre>\n\n\n\n<p>and add an<code>.env<\/code> file containing the correctly configured ENV<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"># .env\n\nDATABASE_NAME=\"development\"\n\nDATABASE_USER=\"postgres\"\n\nDATABASE_PASSWORD=\"postgres\"\n\nDATABASE_HOST=\"localhost\"\n\nDATABASE_PORT=\"5432\"<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li>\n<p>At this stage, we should be able to run the <code>rake db:create<\/code> command which will create the database<\/p>\n<figure><img decoding=\"async\" title=\"Ruby web application\" src=\"\/app\/uploads\/2024\/05\/ruby-web-application.png\" alt=\"Ruby web application\"><\/figure><p><\/p>\n<\/li>\n\n\n\n<li>\n<p>Let&#8217;s try adding a new migration via <code>rake db:new_migration name=<\/code>, where we create a <code>posts<\/code> table with a <code>:title<\/code> column<\/p>\n<figure><img decoding=\"async\" title=\"Rails web application\" src=\"\/app\/uploads\/2024\/05\/rails-web-application.png\" alt=\"Rails web application\"><\/figure><p><\/p>\n<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"># frozen_string_literal: true\n\nclass CreatePosts &lt; ActiveRecord::Migration[6.0]\n\n  def change\n\n    create_table :posts do |t|\n\n      t.string :title\n\n    end\n\n  end\n\nend\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/app\/uploads\/2024\/05\/ruby-on-rails-web-application.png\" alt=\"Ruby on Rails web application\" title=\"Ruby on Rails web application\"\/><\/figure>\n\n\n\n<p>You should notice that the <code>db\/migrate<\/code> directory was automatically added and <code>schema.rb<\/code> was created after successful migration. Currently, our project structure looks as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"> tree\n.\n\u251c\u2500\u2500 Gemfile\n\u251c\u2500\u2500 Gemfile.lock\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 Rakefile\n\u251c\u2500\u2500 .gitignore\n\u251c\u2500\u2500 .env.example\n\u251c\u2500\u2500 app\n\u2502   \u2514\u2500\u2500 application.rb\n\u251c\u2500\u2500 db\n\u2502   \u251c\u2500\u2500 config.yml\n\u2502   \u251c\u2500\u2500 migrate\n\u2502   \u2502   \u2514\u2500\u2500 20210504135128_create_posts.rb\n\u2502   \u2514\u2500\u2500 schema.rb\n\u2514\u2500\u2500 docker-compose.yml<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Active Record<\/h2>\n\n\n\n<p>The last but not least, another step in creating our application is to add <code>activerecord<\/code> and its configuration. For this, we will need to update our Gemfile with 3 more gems:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\">gem 'activerecord'\ngem 'erb'\ngem 'yaml'<\/code><\/pre>\n\n\n\n<p>Why we add <code>erb<\/code> and <code>ymal<\/code> is explained below in the comments. The entire <code>active_record<\/code> configuration will be in the <code>app\/application.rb<\/code> file.<\/p>\n\n\n\n<p>Let&#8217;s go through what happens here, one by one:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"># frozen_string_literal: true\n\n# If we want to be able to run the application in different environments,\n# e.g. test or production, it is good to set the ENVIRONMENT value\n# at the beginning, which is taken from the environment variable\n# or `development` by default.\n\nENV['ENVIRONMENT'] ||= 'development'\n\n# To use the added gems, we need to load them using the Kernel#require method,\n# which loads the file or library passed as a parameter\n\nrequire 'pg'\nrequire 'active_record'\nrequire 'dotenv'\nrequire 'yaml'\nrequire 'erb'\n\n# By default Dotenv.load for loading environment variables reaches out\n# to the `.env` file, so if we want to use other environments it is worth\n# extending this to the method below, which will first for a set development\n# environment look for a file ending in `.env.development.local`,\n# then `.env.development` and finally `.env`.\n\nDotenv.load(\".env.#{ENV.fetch('ENVIRONMENT')}.local\", \".env.#{ENV.fetch('ENVIRONMENT')}\", '.env')\n\n# Method needed for loading database settings\ndef db_configuration\n  # The method below returns the path to the file with our configuration\n  db_configuration_file_path = File.join(File.expand_path('..', __dir__), 'db', 'config.yml')\n\n  # Having the path to the file, we can read its values. Because the config.yml\n  # file contains environment variables and, as you may have noticed,\n  # the erb &lt;%= %> syntax, we also need to use the erb gem. Without this,\n  # the values of the variables will not be read correctly and activerecord\n  # will not be able to connect to postgres.The following method will return\n  # the configuration as a string\n\n  db_configuration_result = ERB.new(File.read(db_configuration_file_path)).result\n\n  # Using the previously added `yaml` gem, we can safely load our configuration\n\n  YAML.safe_load(db_configuration_result, aliases: true)\nend\n\n# Finally, we need to create a connection between activerecord and postgres\n# using the `establish_connection` method\nActiveRecord::Base.establish_connection(db_configuration[ENV['ENVIRONMENT']])\n\nmodule Application\n  class Error &lt; StandardError; end\n  # Your code goes here...\nend<\/code><\/pre>\n\n\n\n<p>We already have the configurations, so we can add the Post model in our <strong>ruby<\/strong> app.\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\">`\u251c\u2500\u2500 app`\n\n`\u2502   \u2514\u2500\u2500 models`\n\n`\u2502       \u2514\u2500\u2500 post.rb`<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\">app\/models\/post.rb\n# frozen_string_literal: true\n\nclass Post &lt; ActiveRecord::Base;end\n<\/code><\/pre>\n\n\n\n<p>and remember to load the file in <code>application.rb<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">require 'app\/models\/post'<\/code><\/pre>\n\n\n\n<p>Also, remember to add require <code>'app\/runner'<\/code> to <code>app\/application.rb<\/code><\/p>\n\n\n\n<p>If we want to add new files in our application, services, more models, we need to load them in <code>application.rb<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SUMMARY<\/h2>\n\n\n\n<p>Currently, our ruby application is ready to continue. We have configured:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>database connection,<\/li>\n\n\n\n<li>Active Record,<\/li>\n\n\n\n<li>Standalone migrations with rake<\/li>\n<\/ul>\n\n\n\n<p>As you can see, it is not always necessary to use <code>rails new<\/code>. This way we avoid unnecessary code in our application that is not used. We have more control over the development of our application. We can add more libraries and business logic over time. We can use such configured application to create a crawler or scraper, connect to external <a href=\"https:\/\/thecodest.co\/en\/blog\/compare-staff-augmentation-firms-that-excel-in-api-team-staffing-for-financial-technology-projects\/\">API<\/a> from which we will retrieve information and store in our own database or load files and extract interesting information from them. I wish you good luck with the further development of your own applications!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">BONUS<\/h2>\n\n\n\n<p>Our application also needs to be started somehow. We can do it in several ways, for example from the terminal. We can create an <code>exe\/app<\/code> file that will load our application logic from the <code>'app\/application'<\/code> file and run our application through the <code>Runner<\/code> service added in the app directory.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\">#!\/usr\/bin\/env ruby\n# frozen_string_literal: true\n\nrequire 'bundler\/setup'\n\n$LOAD_PATH.unshift File.expand_path('..', __dir__)\nrequire 'app\/application'\n\nRunner.start<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"ruby\" class=\"language-ruby\"># frozen_string_literal: true\n\nclass Runner\n  def self.start\n    puts 'Start'\n  end\nend<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\/app\/uploads\/2024\/05\/ruby_app_development.png\" alt=\"ruby app development\" title=\"ruby app development\"\/><\/figure>\n\n\n\n<p>Also remember to add&nbsp;<code>require 'app\/runner'<\/code>&nbsp;to&nbsp;<code>app\/application.rb<\/code><\/p>\n\n\n\n<p>Code can be found on GitHub:<\/p>\n\n\n\n<p>&#8211; <a href=\"https:\/\/github.com\/dwatek\/simple_ruby_app\" rel=\"nofollow\">https:\/\/github.com\/dwatek\/simple<em>ruby<\/em>app<\/a><\/p>\n\n\n\n<p><b>Read More<\/b><\/p>\n\n\n\n<p><a href=\"https:\/\/thecodest.co\/blog\/graphql-ruby-what-about-performance\">GraphQL Ruby. What about performance?<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/thecodest.co\/blog\/rails-and-other-means-of-transport\">Rails and Other Means of Transport<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/thecodest.co\/blog\/rails-development-with-tmux-vim-fzf-ripgrep\">Rails Development with TMUX, Vim, Fzf + Ripgrep<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MVC is a design pattern that divides the responsibilities of an application to make it easier to move about. Rails follows this design pattern by convention.<\/p>\n","protected":false},"author":2,"featured_media":3021,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[8],"tags":[],"class_list":["post-3020","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software-development"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>A Simple Ruby Application from Scratch with Active Record - The Codest<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/thecodest.co\/en\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Simple Ruby Application from Scratch with Active Record\" \/>\n<meta property=\"og:description\" content=\"MVC is a design pattern that divides the responsibilities of an application to make it easier to move about. Rails follows this design pattern by convention.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/thecodest.co\/en\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/\" \/>\n<meta property=\"og:site_name\" content=\"The Codest\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-24T08:53:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-24T11:29:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/thecodest_blog_postruby.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"540\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"thecodest\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"thecodest\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/\"},\"author\":{\"name\":\"thecodest\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#\\\/schema\\\/person\\\/7e3fe41dfa4f4e41a7baad4c6e0d4f76\"},\"headline\":\"A Simple Ruby Application from Scratch with Active Record\",\"datePublished\":\"2020-04-24T08:53:36+00:00\",\"dateModified\":\"2026-04-24T11:29:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/\"},\"wordCount\":1009,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/thecodest_blog_postruby.jpeg\",\"articleSection\":[\"Software Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/\",\"url\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/\",\"name\":\"A Simple Ruby Application from Scratch with Active Record - The Codest\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/thecodest_blog_postruby.jpeg\",\"datePublished\":\"2020-04-24T08:53:36+00:00\",\"dateModified\":\"2026-04-24T11:29:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/#primaryimage\",\"url\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/thecodest_blog_postruby.jpeg\",\"contentUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/05\\\/thecodest_blog_postruby.jpeg\",\"width\":960,\"height\":540},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/blog\\\/a-simple-ruby-application-from-scratch-with-active-record\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/thecodest.co\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A Simple Ruby Application from Scratch with Active Record\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#website\",\"url\":\"https:\\\/\\\/thecodest.co\\\/\",\"name\":\"The Codest\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/thecodest.co\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#organization\",\"name\":\"The Codest\",\"url\":\"https:\\\/\\\/thecodest.co\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/03\\\/thecodest-logo.svg\",\"contentUrl\":\"https:\\\/\\\/thecodest.co\\\/app\\\/uploads\\\/2024\\\/03\\\/thecodest-logo.svg\",\"width\":144,\"height\":36,\"caption\":\"The Codest\"},\"image\":{\"@id\":\"https:\\\/\\\/thecodest.co\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/pl.linkedin.com\\\/company\\\/codest\",\"https:\\\/\\\/clutch.co\\\/profile\\\/codest\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/thecodest.co\\\/#\\\/schema\\\/person\\\/7e3fe41dfa4f4e41a7baad4c6e0d4f76\",\"name\":\"thecodest\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g\",\"caption\":\"thecodest\"},\"url\":\"https:\\\/\\\/thecodest.co\\\/en\\\/author\\\/thecodest\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"A Simple Ruby Application from Scratch with Active Record - The Codest","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:\/\/thecodest.co\/en\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/","og_locale":"en_US","og_type":"article","og_title":"A Simple Ruby Application from Scratch with Active Record","og_description":"MVC is a design pattern that divides the responsibilities of an application to make it easier to move about. Rails follows this design pattern by convention.","og_url":"https:\/\/thecodest.co\/en\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/","og_site_name":"The Codest","article_published_time":"2020-04-24T08:53:36+00:00","article_modified_time":"2026-04-24T11:29:23+00:00","og_image":[{"width":960,"height":540,"url":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/thecodest_blog_postruby.jpeg","type":"image\/jpeg"}],"author":"thecodest","twitter_card":"summary_large_image","twitter_misc":{"Written by":"thecodest","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/#article","isPartOf":{"@id":"https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/"},"author":{"name":"thecodest","@id":"https:\/\/thecodest.co\/#\/schema\/person\/7e3fe41dfa4f4e41a7baad4c6e0d4f76"},"headline":"A Simple Ruby Application from Scratch with Active Record","datePublished":"2020-04-24T08:53:36+00:00","dateModified":"2026-04-24T11:29:23+00:00","mainEntityOfPage":{"@id":"https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/"},"wordCount":1009,"commentCount":0,"publisher":{"@id":"https:\/\/thecodest.co\/#organization"},"image":{"@id":"https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/#primaryimage"},"thumbnailUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/thecodest_blog_postruby.jpeg","articleSection":["Software Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/","url":"https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/","name":"A Simple Ruby Application from Scratch with Active Record - The Codest","isPartOf":{"@id":"https:\/\/thecodest.co\/#website"},"primaryImageOfPage":{"@id":"https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/#primaryimage"},"image":{"@id":"https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/#primaryimage"},"thumbnailUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/thecodest_blog_postruby.jpeg","datePublished":"2020-04-24T08:53:36+00:00","dateModified":"2026-04-24T11:29:23+00:00","breadcrumb":{"@id":"https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/#primaryimage","url":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/thecodest_blog_postruby.jpeg","contentUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/05\/thecodest_blog_postruby.jpeg","width":960,"height":540},{"@type":"BreadcrumbList","@id":"https:\/\/thecodest.co\/blog\/a-simple-ruby-application-from-scratch-with-active-record\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/thecodest.co\/"},{"@type":"ListItem","position":2,"name":"A Simple Ruby Application from Scratch with Active Record"}]},{"@type":"WebSite","@id":"https:\/\/thecodest.co\/#website","url":"https:\/\/thecodest.co\/","name":"The Codest","description":"","publisher":{"@id":"https:\/\/thecodest.co\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/thecodest.co\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/thecodest.co\/#organization","name":"The Codest","url":"https:\/\/thecodest.co\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/thecodest.co\/#\/schema\/logo\/image\/","url":"https:\/\/thecodest.co\/app\/uploads\/2024\/03\/thecodest-logo.svg","contentUrl":"https:\/\/thecodest.co\/app\/uploads\/2024\/03\/thecodest-logo.svg","width":144,"height":36,"caption":"The Codest"},"image":{"@id":"https:\/\/thecodest.co\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/pl.linkedin.com\/company\/codest","https:\/\/clutch.co\/profile\/codest"]},{"@type":"Person","@id":"https:\/\/thecodest.co\/#\/schema\/person\/7e3fe41dfa4f4e41a7baad4c6e0d4f76","name":"thecodest","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5dbfe6a1e8c86e432e8812759e34e6fe82ebac75119ae3237a6c1311fa19caf4?s=96&d=mm&r=g","caption":"thecodest"},"url":"https:\/\/thecodest.co\/en\/author\/thecodest\/"}]}},"_links":{"self":[{"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/posts\/3020","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/comments?post=3020"}],"version-history":[{"count":17,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/posts\/3020\/revisions"}],"predecessor-version":[{"id":7709,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/posts\/3020\/revisions\/7709"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/media\/3021"}],"wp:attachment":[{"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/media?parent=3020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/categories?post=3020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thecodest.co\/en\/wp-json\/wp\/v2\/tags?post=3020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}