{"id":15987234,"url":"https://github.com/loftwah/rails-blog","last_synced_at":"2026-04-11T07:43:37.598Z","repository":{"id":103662577,"uuid":"527968735","full_name":"loftwah/rails-blog","owner":"loftwah","description":"My Rails 7 Blog","archived":false,"fork":false,"pushed_at":"2022-09-01T05:45:22.000Z","size":874,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T22:13:01.507Z","etag":null,"topics":["blog","docker","docker-compose","guide","rails","ruby","tutorial"],"latest_commit_sha":null,"homepage":"","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/loftwah.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"loftwah","custom":["https://paypal.me/loftwah"]}},"created_at":"2022-08-23T11:55:51.000Z","updated_at":"2024-03-11T06:01:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"7cb63f7b-78fa-46cf-b8ef-1f40eac2cfde","html_url":"https://github.com/loftwah/rails-blog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/loftwah/rails-blog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loftwah%2Frails-blog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loftwah%2Frails-blog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loftwah%2Frails-blog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loftwah%2Frails-blog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loftwah","download_url":"https://codeload.github.com/loftwah/rails-blog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loftwah%2Frails-blog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31673067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-10T17:19:37.612Z","status":"online","status_checked_at":"2026-04-11T02:00:05.776Z","response_time":54,"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":["blog","docker","docker-compose","guide","rails","ruby","tutorial"],"created_at":"2024-10-08T03:22:13.679Z","updated_at":"2026-04-11T07:43:37.583Z","avatar_url":"https://github.com/loftwah.png","language":"Ruby","funding_links":["https://github.com/sponsors/loftwah","https://paypal.me/loftwah"],"categories":[],"sub_categories":[],"readme":"# My Rails Tutorial\n\n[Getting Started with Rails](https://guides.rubyonrails.org/getting_started.html) | [API](https://api.rubyonrails.org/) | [Awesome Ruby](https://github.com/markets/awesome-ruby) | [Awesome Rails](https://github.com/gramantin/awesome-rails) | [More than \"Hello World\" in Docker: Build Rails + Sidekiq web apps in Docker](https://dev.to/raphael_jambalos/more-than-hello-world-in-docker-run-rails-sidekiq-web-apps-in-docker-1b37) | [Deploy Rails in Amazon ECS](https://dev.to/raphael_jambalos/deploy-rails-in-amazon-ecs-part-1-concepts-26nl)\n\n![Rails 7 Blog](assets/rails7blog.png)\n\nThis project is to teach myself Ruby on Rails. I am using Ubuntu in WSL2 (Windows Subsystem for Linux 2) and Ruby 2.7. This project requires Ruby and SQLite3. I will be using [this](https://guides.rubyonrails.org/getting_started.html) guide to get started.\n\n\u003c!-- START doctoc generated TOC please keep comment here to allow auto update --\u003e\n\u003c!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --\u003e\n**Table of Contents**\n\n- [Installation](#installation)\n- [Running the Application](#running-the-application)\n- [Docker](#docker)\n- [Screenshots](#screenshots)\n- [Ruby examples](#ruby-examples)\n- [Todo](#todo)\n\n\u003c!-- END doctoc generated TOC please keep comment here to allow auto update --\u003e\n\n## Installation\n\nInstall gpg2\n\n```bash\nsudo apt install gnupg2 -y\n```\n\nImport keys and install RVM (Ruby Version Manager)\n\n```bash\ncurl -sSL https://rvm.io/mpapis.asc | gpg2  --import -\ncurl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -\n\\curl -sSL https://get.rvm.io | bash -s stable\nsource /home/loftwah/.rvm/scripts/rvm\nrvm install 2.7 # Rails 7 requires Ruby 2.7\n```\n\nCheck that Ruby is installed.\n\n```bash\nruby -v        \nruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]\n```\n\nInstall SQLite3\n\n```bash\nsudo apt install sqlite3 -y\nsqlite3 --version\n3.31.1 2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837balt1\n```\n\nJnstall Rails\n\n```bash\ngem install rails\nrails --version\nRails 7.0.3.1\n```\n\nWe can now create a new Blog application as per the guide we are following.\n\n```bash\nrails new blog\n```\n\n\u003e *Note:* `rails new --help` will show you all the options available.\n\nThe following directories will be created and this is the explanation of what they are and what they do.\n\n| File/Folder | Purpose |\n| ------------ | ------- |\n| app/ | Contains the controllers, models, views, helpers, mailers, channels, jobs, and assets for your application. You'll focus on this folder for the remainder of this guide. |\n| bin/ | Contains the `rails` script that starts your app and can contain other scripts you use to set up, update, deploy, or run your application. | \n| config/ | Contains configuration for your application's routes, database, and more. This is covered in more detail in [Configuring Rails Applications](https://guides.rubyonrails.org/configuring.html). |\n| config.ru | Rack configuration for Rack-based servers used to start the application. For more information about Rack, see the [Rack website](https://rack.github.io/). |\n| db/ | Contains your current database schema, as well as the database migrations. |\n| Dockerfile | Contains the Dockerfile and container requirements for your application. |\n| docker-compose.yml | Contains instructions on how to run your application in a Docker container using Docker Compose. |\n| Gemfile \u0026 Gemfile.lock | These files allow you to specify what gem dependencies are needed for your Rails application. These files are used by the Bundler gem. For more information about Bundler, see the [Bundler website](https://bundler.io). |\n| lib/ | Extended modules for your application. |\n| log/ | Application log files. |\n| public/ | Contains static files and compiled assets. When your app is running, this directory will be exposed as-is. |\n| Rakefile | This file locates and loads tasks that can be run from the command line. The task definitions are defined throughout the components of Rails. Rather than changing `Rakefile`, you should add your own tasks by adding files to the `lib/tasks` directory of your application. |\n| README.md | This is a brief instruction manual for your application. You should edit this file to tell others what your application does, how to set it up, and so on. |\n| storage/ | Active Storage files for Disk Service. This is covered in [Active Storage Overview](https://guides.rubyonrails.org/active_storage_overview.html). |\n| test/ | Unit tests, fixtures, and other test apparatus. These are covered in [Testing Rails Applications](https://guides.rubyonrails.org/testing.html). |\n| tmp/ | Temporary files (like cache and pid files). |\n| vendor/ | A place for all third-party code. In a typical Rails application this includes vendored gems. |\n| .gitattributes | This file defines metadata for specific paths in a git repository. This metadata can be used by git and other tools to enhance their behavior. See the [gitattributes documentation](https://git-scm.com/docs/gitattributes) for more information. |\n| .gitignore | This file tells git which files (or patterns) it should ignore. See [GitHub - Ignoring files](https://help.github.com/articles/ignoring-files) for more information about ignoring files. |\n| .ruby-version | This file contains the default Ruby version. |\n\n## Running the Application\n\nTo start the web server, run the following command.\n\n```bash\nbin/rails server\n```\n\nThis starts the Puma web server on port 3000. Navigate to [localhost:3000](http://localhost:3000) to see the application.\n\n## Docker\n\n[Ruby](https://hub.docker.com/_/ruby) | [PostgreSQL](https://hub.docker.com/_/postgres/) | [Adminer](https://hub.docker.com/_/adminer/)\n\nWe can run this application in a Docker container using Docker Compose. If you don't have Docker installed please click [here](https://docs.docker.com/get-docker/) for the instructions.\n\n```bash\ndocker-compose build\ndocker-compose up # or if you want it in the background\ndocker-compose up -d\n```\n\n## Screenshots\n\n| Screenshot | Description |\n| ---------- | ----------- |\n| ![Rails 7 Blog](assets/blog-articles.png) | Blog Articles |\n| ![Rails 7 Blog](assets/read-article.png) | Read Article |\n| ![Rails 7 Blog](assets/adminer.png) | Adminer |\n\n## Ruby examples\n\nThese are some examples of how to do things in Ruby.\n\n- basics\n\n```ruby\n\"Dean\" #=\u003e String\n7         #=\u003e Integer\n6.9       #=\u003e Float\n[1,2,3]   #=\u003e Array\n(1..10)   #=\u003e Range\nfalse     #=\u003e FalseClass (Boolean)\ntrue      #=\u003e TrueClass (Boolean)\nnil       #=\u003e NilClass\nname = \"Dean\"\nname.upcase\n# Print the result of 4 + 8 to the terminal\nputs 4 + 8\nputs name # \"Dean\" \"DEAN\"\n```\n\n- methods\n\n```ruby\n# DRY (Don't Repeat Yourself)!!!!!\n# puts \"Hello Dean, how are you?\"\n# puts \"Hello Scott, how are you?\"\n# puts \"Hello Stephanie, how are you?\"\n# puts \"Hello Luke, how are you?\"\n# method definition (the code inside WON'T RUN until the method is called!)\n# def greet_person\n#   puts \"HI!\"\n# end\n# DRY method with one parameter (name)\ndef greet_student(name)\n  puts \"Hello #{name}, how are you today? :)\"\nend\n# we ommit the () characters if we don't have arguments!\n# greet_person\n# greet_person\n# we're calling the method greet_student with the ARGUMENT 'Dean'\ngreet_student('Dean')\ngreet_student('Scott')\ngreet_student('Stephanie')\ngreet_student('Luke')\ndef full_name(first_name, last_name)\n  first_name = first_name.capitalize\n  last_name = last_name.capitalize\n  return \"#{first_name} #{last_name}\"\nend\n# full_name is returning nil!\nname = full_name('deAn', 'loFtS')\nputs name\ndef max(number_1, number_2)\n  return 0 if number_1 == number_2\n  if number_1 \u003e number_2\n    return number_1\n  else\n    return number_2\n  end\nend\nmaximum = max(5, 6) # =\u003e 6\nputs maximum # =\u003e 6\ndef upcased_name(name)\n  5 + 6\n  new_name = name.downcase\n  # return new_name\n  name.upcase\nend\nupcased = upcased_name('dean')\nputs upcased\ndef stupid_method\nend\nresult = puts('Dean')\nputs result\nrequire 'date'\ndef tomorrow\n  tomorrow_date = Date.today + 1\n  return tomorrow_date.strftime(\"%B %d\")\nend\nputs tomorrow   # =\u003e \"September 2\"\n```\n\n- strings\n\n```ruby\nputs \"Gday mate\"\nputs 'Gday mate'\nname = 'Dean'\nage = 36\n# Concatenation of strings\n# puts 'Hello' + ' ' + name + ' ' + 'how are you?'\nputs 'You are' + ' ' + 36.to_s + ' ' + 'years old'\n# Interpolation of strings (needs double quotes!)\n# puts \"Hello #{name} how are you?\"\nputs \"You are #{35 + 1} years old\"\n```\n\n- variables\n\n```ruby\n# variable names should be lower snake case\nuser_city = 'Melbourne'\nage = 36 # assigning a variable value\nage_in_four_years = age + 4\nage = age + 4 # re-assignment\nage += 4 # sugar syntax to age = age + 4\nputs age #=\u003e 40\nage = 40 # re-assignment\nputs age #=\u003e 40\n```\n\n## Todo\n\n- [ ] Add postgresql\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floftwah%2Frails-blog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floftwah%2Frails-blog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floftwah%2Frails-blog/lists"}