├── log └── .keep ├── storage └── .keep ├── tmp ├── .keep ├── pids │ └── .keep └── storage │ └── .keep ├── vendor ├── .keep └── javascript │ └── .keep ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── public ├── favicon.ico ├── apple-touch-icon.png ├── apple-touch-icon-precomposed.png ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── test ├── helpers │ └── .keep ├── mailers │ └── .keep ├── models │ ├── .keep │ └── post_test.rb ├── system │ ├── .keep │ └── posts_test.rb ├── controllers │ ├── .keep │ └── posts_controller_test.rb ├── integration │ └── .keep ├── fixtures │ ├── files │ │ └── .keep │ └── posts.yml ├── application_system_test_case.rb ├── channels │ └── application_cable │ │ └── connection_test.rb └── test_helper.rb ├── app ├── assets │ ├── images │ │ └── .keep │ ├── config │ │ └── manifest.js │ └── stylesheets │ │ └── application.css ├── models │ ├── concerns │ │ └── .keep │ ├── post.rb │ └── application_record.rb ├── controllers │ ├── concerns │ │ └── .keep │ ├── application_controller.rb │ └── posts_controller.rb ├── views │ ├── layouts │ │ ├── mailer.text.erb │ │ ├── mailer.html.erb │ │ └── application.html.erb │ └── posts │ │ ├── show.json.jbuilder │ │ ├── index.json.jbuilder │ │ ├── _post.json.jbuilder │ │ ├── new.html.erb │ │ ├── edit.html.erb │ │ ├── _post.html.erb │ │ ├── show.html.erb │ │ ├── index.html.erb │ │ └── _form.html.erb ├── helpers │ ├── posts_helper.rb │ └── application_helper.rb ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb ├── mailers │ └── application_mailer.rb ├── javascript │ ├── application.js │ └── controllers │ │ ├── hello_controller.js │ │ ├── application.js │ │ └── index.js └── jobs │ └── application_job.rb ├── .ruby-version ├── bin ├── rake ├── importmap ├── rails ├── docker-entrypoint ├── setup └── bundle ├── config ├── environment.rb ├── boot.rb ├── routes.rb ├── cable.yml ├── importmap.rb ├── initializers │ ├── filter_parameter_logging.rb │ ├── permissions_policy.rb │ ├── assets.rb │ ├── inflections.rb │ └── content_security_policy.rb ├── credentials.yml.enc ├── application.rb ├── database.yml ├── locales │ └── en.yml ├── storage.yml ├── puma.rb └── environments │ ├── development.rb │ ├── test.rb │ └── production.rb ├── .env ├── config.ru ├── Rakefile ├── db ├── migrate │ └── 20230109124036_create_posts.rb └── seeds.rb ├── .gitattributes ├── README.md ├── .gitignore ├── .dockerignore ├── docker-compose.yml ├── Dockerfile ├── Gemfile └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /storage/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/helpers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/mailers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/models/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/system/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/pids/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/storage/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/controllers/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/integration/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/javascript/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ruby-version: -------------------------------------------------------------------------------- 1 | ruby-3.2.0 2 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/fixtures/files/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/helpers/posts_helper.rb: -------------------------------------------------------------------------------- 1 | module PostsHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/models/post.rb: -------------------------------------------------------------------------------- 1 | class Post < ApplicationRecord 2 | end 3 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/views/posts/show.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.partial! "posts/post", post: @post 2 | -------------------------------------------------------------------------------- /app/views/posts/index.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.array! @posts, partial: "posts/post", as: :post 2 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | end 3 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | primary_abstract_class 3 | end 4 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require_relative "../config/boot" 3 | require "rake" 4 | Rake.application.run 5 | -------------------------------------------------------------------------------- /bin/importmap: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | require_relative "../config/application" 4 | require "importmap/commands" 5 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/views/posts/_post.json.jbuilder: -------------------------------------------------------------------------------- 1 | json.extract! post, :id, :title, :body, :created_at, :updated_at 2 | json.url post_url(post, format: :json) 3 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: "from@example.com" 3 | layout "mailer" 4 | end 5 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path("../config/application", __dir__) 3 | require_relative "../config/boot" 4 | require "rails/commands" 5 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative "application" 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /test/models/post_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class PostTest < ActiveSupport::TestCase 4 | # test "the truth" do 5 | # assert true 6 | # end 7 | end 8 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../stylesheets .css 3 | //= link_tree ../../javascript .js 4 | //= link_tree ../../../vendor/javascript .js 5 | -------------------------------------------------------------------------------- /.env: -------------------------------------------------------------------------------- 1 | RAILS_ENV=production 2 | POSTGRES_HOST=db 3 | POSTGRES_DB=videodb_production 4 | POSTGRES_USER=dean 5 | POSTGRES_PASSWORD=password123 6 | RAILS_MASTER_KEY=8af814b3e08d9e263c6635f231fc541f -------------------------------------------------------------------------------- /app/views/posts/new.html.erb: -------------------------------------------------------------------------------- 1 |

New post

2 | 3 | <%= render "form", post: @post %> 4 | 5 |
6 | 7 |
8 | <%= link_to "Back to posts", posts_path %> 9 |
10 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative "config/environment" 4 | 5 | run Rails.application 6 | Rails.application.load_server 7 | -------------------------------------------------------------------------------- /app/javascript/application.js: -------------------------------------------------------------------------------- 1 | // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails 2 | import "@hotwired/turbo-rails" 3 | import "controllers" 4 | -------------------------------------------------------------------------------- /test/application_system_test_case.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class ApplicationSystemTestCase < ActionDispatch::SystemTestCase 4 | driven_by :selenium, using: :chrome, screen_size: [1400, 1400] 5 | end 6 | -------------------------------------------------------------------------------- /app/javascript/controllers/hello_controller.js: -------------------------------------------------------------------------------- 1 | import { Controller } from "@hotwired/stimulus" 2 | 3 | export default class extends Controller { 4 | connect() { 5 | this.element.textContent = "Hello World!" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) 2 | 3 | require "bundler/setup" # Set up gems listed in the Gemfile. 4 | require "bootsnap/setup" # Speed up boot time by caching expensive operations. 5 | -------------------------------------------------------------------------------- /test/fixtures/posts.yml: -------------------------------------------------------------------------------- 1 | # Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html 2 | 3 | one: 4 | title: MyString 5 | body: MyText 6 | 7 | two: 8 | title: MyString 9 | body: MyText 10 | -------------------------------------------------------------------------------- /app/views/posts/edit.html.erb: -------------------------------------------------------------------------------- 1 |

Editing post

2 | 3 | <%= render "form", post: @post %> 4 | 5 |
6 | 7 |
8 | <%= link_to "Show this post", @post %> | 9 | <%= link_to "Back to posts", posts_path %> 10 |
11 | -------------------------------------------------------------------------------- /app/views/posts/_post.html.erb: -------------------------------------------------------------------------------- 1 |
2 |

3 | Title: 4 | <%= post.title %> 5 |

6 | 7 |

8 | Body: 9 | <%= post.body %> 10 |

11 | 12 |
13 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative "config/application" 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /bin/docker-entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # If running the rails server then create or migrate existing database 4 | if [ "${*}" == "./bin/rails server" ]; then 5 | ./bin/rails db:create 6 | ./bin/rails db:prepare 7 | fi 8 | 9 | exec "${@}" 10 | -------------------------------------------------------------------------------- /db/migrate/20230109124036_create_posts.rb: -------------------------------------------------------------------------------- 1 | class CreatePosts < ActiveRecord::Migration[7.1] 2 | def change 3 | create_table :posts do |t| 4 | t.string :title 5 | t.text :body 6 | 7 | t.timestamps 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | root 'posts#index' 3 | resources :posts 4 | # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html 5 | 6 | # Defines the root path route ("/") 7 | # root "articles#index" 8 | end 9 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: redis 3 | url: redis://localhost:6379/1 4 | 5 | test: 6 | adapter: test 7 | 8 | production: 9 | adapter: redis 10 | url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> 11 | channel_prefix: video_production 12 | -------------------------------------------------------------------------------- /app/javascript/controllers/application.js: -------------------------------------------------------------------------------- 1 | import { Application } from "@hotwired/stimulus" 2 | 3 | const application = Application.start() 4 | 5 | // Configure Stimulus development experience 6 | application.debug = false 7 | window.Stimulus = application 8 | 9 | export { application } 10 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | # Automatically retry jobs that encountered a deadlock 3 | # retry_on ActiveRecord::Deadlocked 4 | 5 | # Most jobs are safe to ignore if the underlying records are no longer available 6 | # discard_on ActiveJob::DeserializationError 7 | end 8 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/views/posts/show.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 | <%= render @post %> 4 | 5 |
6 | <%= link_to "Edit this post", edit_post_path(@post) %> | 7 | <%= link_to "Back to posts", posts_path %> 8 | 9 | <%= button_to "Destroy this post", @post, method: :delete %> 10 |
11 | -------------------------------------------------------------------------------- /app/views/posts/index.html.erb: -------------------------------------------------------------------------------- 1 |

<%= notice %>

2 | 3 |

Posts

4 | 5 |
6 | <% @posts.each do |post| %> 7 | <%= render post %> 8 |

9 | <%= link_to "Show this post", post %> 10 |

11 | <% end %> 12 |
13 | 14 | <%= link_to "New post", new_post_path %> 15 | -------------------------------------------------------------------------------- /config/importmap.rb: -------------------------------------------------------------------------------- 1 | # Pin npm packages by running ./bin/importmap 2 | 3 | pin "application", preload: true 4 | pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true 5 | pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true 6 | pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true 7 | pin_all_from "app/javascript/controllers", under: "controllers" 8 | -------------------------------------------------------------------------------- /test/channels/application_cable/connection_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | module ApplicationCable 4 | class ConnectionTest < ActionCable::Connection::TestCase 5 | # test "connects with cookies" do 6 | # cookies.signed[:user_id] = 42 7 | # 8 | # connect 9 | # 10 | # assert_equal connection.user_id, "42" 11 | # end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # See https://git-scm.com/docs/gitattributes for more about git attribute files. 2 | 3 | # Mark the database schema as having been generated. 4 | db/schema.rb linguist-generated 5 | 6 | # Mark any vendored files as having been vendored. 7 | vendor/* linguist-vendored 8 | config/credentials/*.yml.enc diff=rails_credentials 9 | config/credentials.yml.enc diff=rails_credentials 10 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }]) 7 | # Character.create(name: "Luke", movie: movies.first) 8 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Video 5 | 6 | <%= csrf_meta_tags %> 7 | <%= csp_meta_tag %> 8 | 9 | <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> 10 | <%= javascript_importmap_tags %> 11 | 12 | 13 | 14 | <%= yield %> 15 | 16 | 17 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure parameters to be filtered from the log file. Use this to limit dissemination of 4 | # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported 5 | # notations and behaviors. 6 | Rails.application.config.filter_parameters += [ 7 | :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn 8 | ] 9 | -------------------------------------------------------------------------------- /config/credentials.yml.enc: -------------------------------------------------------------------------------- 1 | iPP48bKgATEAKmLApd7vjhlf55l9CCdtD/l5K3owWLGqRlYRLcUHZirLiEKJe8FGs76pSGm9wj6DWqBgF6sYJJLqVVqMv8fl4nwkryAMoZpNP6eYRDgSdkKVD4ioPnxeLX7iUk7pgo7mESeZlKF4XxjJ5/RiV9k+2Tnk7EFmyMHtoEWgVbovKPiWhpTaLj1Bn8jZXDJbDvC3WjyJkAcIgJMn25YWsExxMYDOFhAJN7uzeulyWHRc7bSUEC+RRZQ+IYJ2m/9DFZ6rtX5vGMTHi4E21xayFU/xjAkVsDen4JR90Sb3r6Uv6tPvq4cYrFwJ5eRpZ5kNvDD8yvuM1cRQ3v6/vlHMrAwvT1aDMdBEuD3gyVRX10CFPucOiUIqHvz8Kw6isLuLt0zZozcytVOyjxW09cQr--GpIIBXUWHSweOuDP--Ag93Gg9Vj78e5+poaRhX3w== -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | This README would normally document whatever steps are necessary to get the 4 | application up and running. 5 | 6 | Things you may want to cover: 7 | 8 | * Ruby version 9 | 10 | * System dependencies 11 | 12 | * Configuration 13 | 14 | * Database creation 15 | 16 | * Database initialization 17 | 18 | * How to run the test suite 19 | 20 | * Services (job queues, cache servers, search engines, etc.) 21 | 22 | * Deployment instructions 23 | 24 | * ... 25 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] ||= "test" 2 | require_relative "../config/environment" 3 | require "rails/test_help" 4 | 5 | module ActiveSupport 6 | class TestCase 7 | # Run tests in parallel with specified workers 8 | parallelize(workers: :number_of_processors) 9 | 10 | # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. 11 | fixtures :all 12 | 13 | # Add more helper methods to be used by all tests here... 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /config/initializers/permissions_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide HTTP permissions policy. For further 4 | # information see: https://developers.google.com/web/updates/2018/06/feature-policy 5 | 6 | # Rails.application.config.permissions_policy do |policy| 7 | # policy.camera :none 8 | # policy.gyroscope :none 9 | # policy.microphone :none 10 | # policy.usb :none 11 | # policy.fullscreen :self 12 | # policy.payment :self, "https://secure.example.com" 13 | # end 14 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = "1.0" 5 | 6 | # Add additional assets to the asset load path. 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | 9 | # Precompile additional assets. 10 | # application.js, application.css, and all non-JS/CSS in the app/assets 11 | # folder are already added. 12 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 13 | -------------------------------------------------------------------------------- /app/javascript/controllers/index.js: -------------------------------------------------------------------------------- 1 | // Import and register all your controllers from the importmap under controllers/* 2 | 3 | import { application } from "controllers/application" 4 | 5 | // Eager load all controllers defined in the import map under controllers/**/*_controller 6 | import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" 7 | eagerLoadControllersFrom("controllers", application) 8 | 9 | // Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!) 10 | // import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading" 11 | // lazyLoadControllersFrom("controllers", application) 12 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, "\\1en" 8 | # inflect.singular /^(ox)en/i, "\\1" 9 | # inflect.irregular "person", "people" 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym "RESTful" 16 | # end 17 | -------------------------------------------------------------------------------- /app/views/posts/_form.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_with(model: post) do |form| %> 2 | <% if post.errors.any? %> 3 |
4 |

<%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:

5 | 6 | 11 |
12 | <% end %> 13 | 14 |
15 | <%= form.label :title, style: "display: block" %> 16 | <%= form.text_field :title %> 17 |
18 | 19 |
20 | <%= form.label :body, style: "display: block" %> 21 | <%= form.text_area :body %> 22 |
23 | 24 |
25 | <%= form.submit %> 26 |
27 | <% end %> 28 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative "boot" 2 | 3 | require "rails/all" 4 | 5 | # Require the gems listed in Gemfile, including any gems 6 | # you've limited to :test, :development, or :production. 7 | Bundler.require(*Rails.groups) 8 | 9 | module Video 10 | class Application < Rails::Application 11 | # Initialize configuration defaults for originally generated Rails version. 12 | config.load_defaults 7.1 13 | 14 | # Configuration for the application, engines, and railties goes here. 15 | # 16 | # These settings can be overridden in specific environments using the files 17 | # in config/environments, which are processed later. 18 | # 19 | # config.time_zone = "Central Time (US & Canada)" 20 | # config.eager_load_paths << Rails.root.join("extras") 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | 2 | default: &default 3 | adapter: postgresql 4 | encoding: unicode 5 | # For details on connection pooling, see Rails configuration guide 6 | # https://guides.rubyonrails.org/configuring.html#database-pooling 7 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 8 | host: <%= ENV['POSTGRES_HOST'] %> 9 | port: 5432 10 | 11 | development: 12 | <<: *default 13 | database: video_development 14 | username: <%= ENV['POSTGRES_USER'] %> 15 | password: <%= ENV['POSTGRES_PASSWORD'] %> 16 | 17 | test: 18 | <<: *default 19 | database: video_test 20 | username: <%= ENV['POSTGRES_USER'] %> 21 | password: <%= ENV['POSTGRES_PASSWORD'] %> 22 | 23 | production: 24 | <<: *default 25 | database: <%= ENV['POSTGRES_DB'] %> 26 | username: <%= ENV['POSTGRES_USER'] %> 27 | password: <%= ENV['POSTGRES_PASSWORD'] %> -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all logfiles and tempfiles. 11 | /log/* 12 | /tmp/* 13 | !/log/.keep 14 | !/tmp/.keep 15 | 16 | # Ignore pidfiles, but keep the directory. 17 | /tmp/pids/* 18 | !/tmp/pids/ 19 | !/tmp/pids/.keep 20 | 21 | # Ignore storage (uploaded files in development and any SQLite databases). 22 | /storage/* 23 | !/storage/.keep 24 | /tmp/storage/* 25 | !/tmp/storage/ 26 | !/tmp/storage/.keep 27 | 28 | /public/assets 29 | 30 | # Ignore master key for decrypting credentials and more. 31 | /config/master.key -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. 2 | 3 | # Ignore git directory. 4 | /.git/ 5 | 6 | # Ignore bundler config. 7 | /.bundle 8 | 9 | # Ignore all default key files. 10 | /config/master.key 11 | /config/credentials/*.key 12 | 13 | # Ignore all environment files. 14 | /.env* 15 | !/.env.example 16 | 17 | # Ignore all logfiles and tempfiles. 18 | /log/* 19 | /tmp/* 20 | !/log/.keep 21 | !/tmp/.keep 22 | 23 | # Ignore pidfiles, but keep the directory. 24 | /tmp/pids/* 25 | !/tmp/pids/ 26 | !/tmp/pids/.keep 27 | 28 | # Ignore storage (uploaded files in development and any SQLite databases). 29 | /storage/* 30 | !/storage/.keep 31 | /tmp/storage/* 32 | !/tmp/storage/ 33 | !/tmp/storage/.keep 34 | 35 | # Ignore assets. 36 | /node_modules/ 37 | /app/assets/builds/* 38 | !/app/assets/builds/.keep 39 | /public/assets 40 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t "hello" 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t("hello") %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # "true": "foo" 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at https://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | db: 4 | image: postgres:14.2-alpine 5 | container_name: demo-postgres-14.2 6 | volumes: 7 | - postgres_data:/var/lib/postgresql/data 8 | command: 9 | "postgres -c 'max_connections=500'" 10 | environment: 11 | - POSTGRES_DB=${POSTGRES_DB} 12 | - POSTGRES_USER=${POSTGRES_USER} 13 | - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} 14 | ports: 15 | - "5432:5432" 16 | demo-web: 17 | build: . 18 | command: "./bin/rails server" 19 | environment: 20 | - RAILS_ENV=${RAILS_ENV} 21 | - POSTGRES_HOST=${POSTGRES_HOST} 22 | - POSTGRES_DB=${POSTGRES_DB} 23 | - POSTGRES_USER=${POSTGRES_USER} 24 | - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} 25 | - RAILS_MASTER_KEY=${RAILS_MASTER_KEY} 26 | volumes: 27 | - app-storage:/rails/storage 28 | depends_on: 29 | - db 30 | ports: 31 | - "3000:3000" 32 | 33 | volumes: 34 | postgres_data: {} 35 | app-storage: {} -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require "fileutils" 3 | 4 | # path to your application root. 5 | APP_ROOT = File.expand_path("..", __dir__) 6 | 7 | def system!(*args) 8 | system(*args, exception: true) 9 | end 10 | 11 | FileUtils.chdir APP_ROOT do 12 | # This script is a way to set up or update your development environment automatically. 13 | # This script is idempotent, so that you can run it at any time and get an expectable outcome. 14 | # Add necessary setup steps to this file. 15 | 16 | puts "== Installing dependencies ==" 17 | system! "gem install bundler --conservative" 18 | system("bundle check") || system!("bundle install") 19 | 20 | # puts "\n== Copying sample files ==" 21 | # unless File.exist?("config/database.yml") 22 | # FileUtils.cp "config/database.yml.sample", "config/database.yml" 23 | # end 24 | 25 | puts "\n== Preparing database ==" 26 | system! "bin/rails db:prepare" 27 | 28 | puts "\n== Removing old logs and tempfiles ==" 29 | system! "bin/rails log:clear tmp:clear" 30 | 31 | puts "\n== Restarting application server ==" 32 | system! "bin/rails restart" 33 | end 34 | -------------------------------------------------------------------------------- /test/system/posts_test.rb: -------------------------------------------------------------------------------- 1 | require "application_system_test_case" 2 | 3 | class PostsTest < ApplicationSystemTestCase 4 | setup do 5 | @post = posts(:one) 6 | end 7 | 8 | test "visiting the index" do 9 | visit posts_url 10 | assert_selector "h1", text: "Posts" 11 | end 12 | 13 | test "should create post" do 14 | visit posts_url 15 | click_on "New post" 16 | 17 | fill_in "Body", with: @post.body 18 | fill_in "Title", with: @post.title 19 | click_on "Create Post" 20 | 21 | assert_text "Post was successfully created" 22 | click_on "Back" 23 | end 24 | 25 | test "should update Post" do 26 | visit post_url(@post) 27 | click_on "Edit this post", match: :first 28 | 29 | fill_in "Body", with: @post.body 30 | fill_in "Title", with: @post.title 31 | click_on "Update Post" 32 | 33 | assert_text "Post was successfully updated" 34 | click_on "Back" 35 | end 36 | 37 | test "should destroy Post" do 38 | visit post_url(@post) 39 | click_on "Destroy this post", match: :first 40 | 41 | assert_text "Post was successfully destroyed" 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /config/initializers/content_security_policy.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Define an application-wide content security policy. 4 | # See the Securing Rails Applications Guide for more information: 5 | # https://guides.rubyonrails.org/security.html#content-security-policy-header 6 | 7 | # Rails.application.configure do 8 | # config.content_security_policy do |policy| 9 | # policy.default_src :self, :https 10 | # policy.font_src :self, :https, :data 11 | # policy.img_src :self, :https, :data 12 | # policy.object_src :none 13 | # policy.script_src :self, :https 14 | # policy.style_src :self, :https 15 | # # Specify URI for violation reports 16 | # # policy.report_uri "/csp-violation-report-endpoint" 17 | # end 18 | # 19 | # # Generate session nonces for permitted importmap, inline scripts, and inline styles. 20 | # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } 21 | # config.content_security_policy_nonce_directives = %w(script-src style-src) 22 | # 23 | # # Report violations without enforcing the policy. 24 | # # config.content_security_policy_report_only = true 25 | # end 26 | -------------------------------------------------------------------------------- /test/controllers/posts_controller_test.rb: -------------------------------------------------------------------------------- 1 | require "test_helper" 2 | 3 | class PostsControllerTest < ActionDispatch::IntegrationTest 4 | setup do 5 | @post = posts(:one) 6 | end 7 | 8 | test "should get index" do 9 | get posts_url 10 | assert_response :success 11 | end 12 | 13 | test "should get new" do 14 | get new_post_url 15 | assert_response :success 16 | end 17 | 18 | test "should create post" do 19 | assert_difference("Post.count") do 20 | post posts_url, params: { post: { body: @post.body, title: @post.title } } 21 | end 22 | 23 | assert_redirected_to post_url(Post.last) 24 | end 25 | 26 | test "should show post" do 27 | get post_url(@post) 28 | assert_response :success 29 | end 30 | 31 | test "should get edit" do 32 | get edit_post_url(@post) 33 | assert_response :success 34 | end 35 | 36 | test "should update post" do 37 | patch post_url(@post), params: { post: { body: @post.body, title: @post.title } } 38 | assert_redirected_to post_url(@post) 39 | end 40 | 41 | test "should destroy post" do 42 | assert_difference("Post.count", -1) do 43 | delete post_url(@post) 44 | end 45 | 46 | assert_redirected_to posts_url 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /config/storage.yml: -------------------------------------------------------------------------------- 1 | test: 2 | service: Disk 3 | root: <%= Rails.root.join("tmp/storage") %> 4 | 5 | local: 6 | service: Disk 7 | root: <%= Rails.root.join("storage") %> 8 | 9 | # Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) 10 | # amazon: 11 | # service: S3 12 | # access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> 13 | # secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> 14 | # region: us-east-1 15 | # bucket: your_own_bucket-<%= Rails.env %> 16 | 17 | # Remember not to checkin your GCS keyfile to a repository 18 | # google: 19 | # service: GCS 20 | # project: your_project 21 | # credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> 22 | # bucket: your_own_bucket-<%= Rails.env %> 23 | 24 | # Use bin/rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) 25 | # microsoft: 26 | # service: AzureStorage 27 | # storage_account_name: your_account_name 28 | # storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> 29 | # container: your_container_name-<%= Rails.env %> 30 | 31 | # mirror: 32 | # service: Mirror 33 | # primary: local 34 | # mirrors: [ amazon, google, microsoft ] 35 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Make sure it matches the Ruby version in .ruby-version and Gemfile 2 | ARG RUBY_VERSION=3.2.0 3 | FROM ruby:$RUBY_VERSION 4 | 5 | # Install libvips for Active Storage preview support 6 | RUN apt-get update -qq && \ 7 | apt-get install -y build-essential libvips bash bash-completion libffi-dev tzdata postgresql nodejs npm yarn && \ 8 | apt-get clean && \ 9 | rm -rf /var/lib/apt/lists/* /usr/share/doc /usr/share/man 10 | 11 | # Rails app lives here 12 | WORKDIR /rails 13 | 14 | # Set production environment 15 | ENV RAILS_LOG_TO_STDOUT="1" \ 16 | RAILS_SERVE_STATIC_FILES="true" \ 17 | RAILS_ENV="production" \ 18 | BUNDLE_WITHOUT="development" 19 | 20 | # Install application gems 21 | COPY Gemfile Gemfile.lock ./ 22 | RUN bundle install 23 | 24 | # Copy application code 25 | COPY . . 26 | 27 | # Precompile bootsnap code for faster boot times 28 | RUN bundle exec bootsnap precompile --gemfile app/ lib/ 29 | 30 | # Precompiling assets for production without requiring secret RAILS_MASTER_KEY 31 | RUN SECRET_KEY_BASE_DUMMY=1 bundle exec rails assets:precompile 32 | 33 | # Entrypoint prepares the database. 34 | ENTRYPOINT ["/rails/bin/docker-entrypoint"] 35 | 36 | # Start the server by default, this can be overwritten at runtime 37 | EXPOSE 3000 38 | CMD ["./bin/rails", "server"] 39 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # This configuration file will be evaluated by Puma. The top-level methods that 2 | # are invoked here are part of Puma's configuration DSL. For more information 3 | # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. 4 | 5 | # Puma can serve each request in a thread from an internal thread pool. 6 | # The `threads` method setting takes two numbers: a minimum and maximum. 7 | # Any libraries that use thread pools should be configured to match 8 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 9 | # and maximum; this matches the default thread size of Active Record. 10 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 11 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } 12 | threads min_threads_count, max_threads_count 13 | 14 | # Specifies that the worker count should equal the number of processors in production. 15 | if ENV["RAILS_ENV"] == "production" 16 | worker_count = Integer(ENV.fetch("WEB_CONCURRENCY") { Concurrent.physical_processor_count }) 17 | workers worker_count if worker_count > 1 18 | end 19 | 20 | # Specifies the `worker_timeout` threshold that Puma will use to wait before 21 | # terminating a worker in development environments. 22 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" 23 | 24 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 25 | port ENV.fetch("PORT") { 3000 } 26 | 27 | # Specifies the `environment` that Puma will run in. 28 | environment ENV.fetch("RAILS_ENV") { "development" } 29 | 30 | # Specifies the `pidfile` that Puma will use. 31 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" } 32 | 33 | # Allow puma to be restarted by `bin/rails restart` command. 34 | plugin :tmp_restart 35 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /app/controllers/posts_controller.rb: -------------------------------------------------------------------------------- 1 | class PostsController < ApplicationController 2 | before_action :set_post, only: %i[ show edit update destroy ] 3 | 4 | # GET /posts or /posts.json 5 | def index 6 | @posts = Post.all 7 | end 8 | 9 | # GET /posts/1 or /posts/1.json 10 | def show 11 | end 12 | 13 | # GET /posts/new 14 | def new 15 | @post = Post.new 16 | end 17 | 18 | # GET /posts/1/edit 19 | def edit 20 | end 21 | 22 | # POST /posts or /posts.json 23 | def create 24 | @post = Post.new(post_params) 25 | 26 | respond_to do |format| 27 | if @post.save 28 | format.html { redirect_to post_url(@post), notice: "Post was successfully created." } 29 | format.json { render :show, status: :created, location: @post } 30 | else 31 | format.html { render :new, status: :unprocessable_entity } 32 | format.json { render json: @post.errors, status: :unprocessable_entity } 33 | end 34 | end 35 | end 36 | 37 | # PATCH/PUT /posts/1 or /posts/1.json 38 | def update 39 | respond_to do |format| 40 | if @post.update(post_params) 41 | format.html { redirect_to post_url(@post), notice: "Post was successfully updated." } 42 | format.json { render :show, status: :ok, location: @post } 43 | else 44 | format.html { render :edit, status: :unprocessable_entity } 45 | format.json { render json: @post.errors, status: :unprocessable_entity } 46 | end 47 | end 48 | end 49 | 50 | # DELETE /posts/1 or /posts/1.json 51 | def destroy 52 | @post.destroy! 53 | 54 | respond_to do |format| 55 | format.html { redirect_to posts_url, notice: "Post was successfully destroyed." } 56 | format.json { head :no_content } 57 | end 58 | end 59 | 60 | private 61 | # Use callbacks to share common setup or constraints between actions. 62 | def set_post 63 | @post = Post.find(params[:id]) 64 | end 65 | 66 | # Only allow a list of trusted parameters through. 67 | def post_params 68 | params.require(:post).permit(:title, :body) 69 | end 70 | end 71 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | ruby "3.2.0" 5 | 6 | # Use main development branch of Rails 7 | gem "rails", github: "rails/rails", branch: "main" 8 | 9 | # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] 10 | gem "sprockets-rails" 11 | 12 | # Use postgresql as the database for Active Record 13 | gem "pg", "~> 1.1" 14 | 15 | # Use the Puma web server [https://github.com/puma/puma] 16 | gem "puma", ">= 5.0" 17 | 18 | # Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] 19 | gem "importmap-rails" 20 | 21 | # Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] 22 | gem "turbo-rails" 23 | 24 | # Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] 25 | gem "stimulus-rails" 26 | 27 | # Build JSON APIs with ease [https://github.com/rails/jbuilder] 28 | gem "jbuilder" 29 | 30 | # Use Redis adapter to run Action Cable in production 31 | gem "redis", ">= 4.0.1" 32 | 33 | # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] 34 | # gem "kredis" 35 | 36 | # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] 37 | # gem "bcrypt", "~> 3.1.7" 38 | 39 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 40 | gem "tzinfo-data", platforms: %i[ windows jruby ] 41 | 42 | # Reduces boot times through caching; required in config/boot.rb 43 | gem "bootsnap", require: false 44 | 45 | # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] 46 | # gem "image_processing", "~> 1.2" 47 | 48 | group :development, :test do 49 | # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem 50 | gem "debug", platforms: %i[ mri windows ] 51 | end 52 | 53 | group :development do 54 | # Use console on exceptions pages [https://github.com/rails/web-console] 55 | gem "web-console" 56 | 57 | # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] 58 | # gem "rack-mini-profiler" 59 | 60 | # Speed up commands on slow machines / big apps [https://github.com/rails/spring] 61 | # gem "spring" 62 | 63 | gem "error_highlight", ">= 0.4.0", platforms: [:ruby] 64 | end 65 | 66 | group :test do 67 | # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] 68 | gem "capybara" 69 | gem "selenium-webdriver" 70 | gem "webdrivers" 71 | end 72 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # In the development environment your application's code is reloaded any time 7 | # it changes. This slows down response time but is perfect for development 8 | # since you don't have to restart the web server when you make code changes. 9 | config.enable_reloading = true 10 | 11 | # Do not eager load code on boot. 12 | config.eager_load = false 13 | 14 | # Show full error reports. 15 | config.consider_all_requests_local = true 16 | 17 | # Enable server timing 18 | config.server_timing = true 19 | 20 | # Enable/disable caching. By default caching is disabled. 21 | # Run rails dev:cache to toggle caching. 22 | if Rails.root.join("tmp/caching-dev.txt").exist? 23 | config.action_controller.perform_caching = true 24 | config.action_controller.enable_fragment_cache_logging = true 25 | 26 | config.cache_store = :memory_store 27 | config.public_file_server.headers = { 28 | "Cache-Control" => "public, max-age=#{2.days.to_i}" 29 | } 30 | else 31 | config.action_controller.perform_caching = false 32 | 33 | config.cache_store = :null_store 34 | end 35 | 36 | # Store uploaded files on the local file system (see config/storage.yml for options). 37 | config.active_storage.service = :local 38 | 39 | # Don't care if the mailer can't send. 40 | config.action_mailer.raise_delivery_errors = false 41 | 42 | config.action_mailer.perform_caching = false 43 | 44 | # Print deprecation notices to the Rails logger. 45 | config.active_support.deprecation = :log 46 | 47 | # Raise exceptions for disallowed deprecations. 48 | config.active_support.disallowed_deprecation = :raise 49 | 50 | # Tell Active Support which deprecation messages to disallow. 51 | config.active_support.disallowed_deprecation_warnings = [] 52 | 53 | # Raise an error on page load if there are pending migrations. 54 | config.active_record.migration_error = :page_load 55 | 56 | # Highlight code that triggered database queries in logs. 57 | config.active_record.verbose_query_logs = true 58 | 59 | # Suppress logger output for asset requests. 60 | config.assets.quiet = true 61 | 62 | # Raises error for missing translations. 63 | # config.i18n.raise_on_missing_translations = true 64 | 65 | # Annotate rendered view with file names. 66 | # config.action_view.annotate_rendered_view_with_filenames = true 67 | 68 | # Uncomment if you wish to allow Action Cable access from any origin. 69 | # config.action_cable.disable_request_forgery_protection = true 70 | 71 | # Raise error when a before_action's only/except options reference missing actions 72 | config.action_controller.raise_on_missing_callback_actions = true 73 | end 74 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | # The test environment is used exclusively to run your application's 4 | # test suite. You never need to work with it otherwise. Remember that 5 | # your test database is "scratch space" for the test suite and is wiped 6 | # and recreated between test runs. Don't rely on the data there! 7 | 8 | Rails.application.configure do 9 | # Settings specified here will take precedence over those in config/application.rb. 10 | 11 | # While tests run files are not watched, reloading is not necessary. 12 | config.enable_reloading = false 13 | 14 | # Eager loading loads your entire application. When running a single test locally, 15 | # this is usually not necessary, and can slow down your test suite. However, it's 16 | # recommended that you enable it in continuous integration systems to ensure eager 17 | # loading is working properly before deploying your code. 18 | config.eager_load = ENV["CI"].present? 19 | 20 | # Configure public file server for tests with Cache-Control for performance. 21 | config.public_file_server.enabled = true 22 | config.public_file_server.headers = { 23 | "Cache-Control" => "public, max-age=#{1.hour.to_i}" 24 | } 25 | 26 | # Show full error reports and disable caching. 27 | config.consider_all_requests_local = true 28 | config.action_controller.perform_caching = false 29 | config.cache_store = :null_store 30 | 31 | # Raise exceptions instead of rendering exception templates. 32 | config.action_dispatch.show_exceptions = false 33 | 34 | # Disable request forgery protection in test environment. 35 | config.action_controller.allow_forgery_protection = false 36 | 37 | # Store uploaded files on the local file system in a temporary directory. 38 | config.active_storage.service = :test 39 | 40 | config.action_mailer.perform_caching = false 41 | 42 | # Tell Action Mailer not to deliver emails to the real world. 43 | # The :test delivery method accumulates sent emails in the 44 | # ActionMailer::Base.deliveries array. 45 | config.action_mailer.delivery_method = :test 46 | 47 | # Print deprecation notices to the stderr. 48 | config.active_support.deprecation = :stderr 49 | 50 | # Raise exceptions for disallowed deprecations. 51 | config.active_support.disallowed_deprecation = :raise 52 | 53 | # Tell Active Support which deprecation messages to disallow. 54 | config.active_support.disallowed_deprecation_warnings = [] 55 | 56 | # Raises error for missing translations. 57 | # config.i18n.raise_on_missing_translations = true 58 | 59 | # Annotate rendered view with file names. 60 | # config.action_view.annotate_rendered_view_with_filenames = true 61 | 62 | # Raise error when a before_action's only/except options reference missing actions 63 | config.action_controller.raise_on_missing_callback_actions = true 64 | end 65 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # frozen_string_literal: true 3 | 4 | # 5 | # This file was generated by Bundler. 6 | # 7 | # The application 'bundle' is installed as part of a gem, and 8 | # this file is here to facilitate running it. 9 | # 10 | 11 | require "rubygems" 12 | 13 | m = Module.new do 14 | module_function 15 | 16 | def invoked_as_script? 17 | File.expand_path($0) == File.expand_path(__FILE__) 18 | end 19 | 20 | def env_var_version 21 | ENV["BUNDLER_VERSION"] 22 | end 23 | 24 | def cli_arg_version 25 | return unless invoked_as_script? # don't want to hijack other binstubs 26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update` 27 | bundler_version = nil 28 | update_index = nil 29 | ARGV.each_with_index do |a, i| 30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN 31 | bundler_version = a 32 | end 33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/ 34 | bundler_version = $1 35 | update_index = i 36 | end 37 | bundler_version 38 | end 39 | 40 | def gemfile 41 | gemfile = ENV["BUNDLE_GEMFILE"] 42 | return gemfile if gemfile && !gemfile.empty? 43 | 44 | File.expand_path("../Gemfile", __dir__) 45 | end 46 | 47 | def lockfile 48 | lockfile = 49 | case File.basename(gemfile) 50 | when "gems.rb" then gemfile.sub(/\.rb$/, gemfile) 51 | else "#{gemfile}.lock" 52 | end 53 | File.expand_path(lockfile) 54 | end 55 | 56 | def lockfile_version 57 | return unless File.file?(lockfile) 58 | lockfile_contents = File.read(lockfile) 59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/ 60 | Regexp.last_match(1) 61 | end 62 | 63 | def bundler_requirement 64 | @bundler_requirement ||= 65 | env_var_version || 66 | cli_arg_version || 67 | bundler_requirement_for(lockfile_version) 68 | end 69 | 70 | def bundler_requirement_for(version) 71 | return "#{Gem::Requirement.default}.a" unless version 72 | 73 | bundler_gem_version = Gem::Version.new(version) 74 | 75 | bundler_gem_version.approximate_recommendation 76 | end 77 | 78 | def load_bundler! 79 | ENV["BUNDLE_GEMFILE"] ||= gemfile 80 | 81 | activate_bundler 82 | end 83 | 84 | def activate_bundler 85 | gem_error = activation_error_handling do 86 | gem "bundler", bundler_requirement 87 | end 88 | return if gem_error.nil? 89 | require_error = activation_error_handling do 90 | require "bundler/version" 91 | end 92 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION)) 93 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`" 94 | exit 42 95 | end 96 | 97 | def activation_error_handling 98 | yield 99 | nil 100 | rescue StandardError, LoadError => e 101 | e 102 | end 103 | end 104 | 105 | m.load_bundler! 106 | 107 | if m.invoked_as_script? 108 | load Gem.bin_path("bundler", "bundle") 109 | end 110 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | require "active_support/core_ext/integer/time" 2 | 3 | Rails.application.configure do 4 | # Settings specified here will take precedence over those in config/application.rb. 5 | 6 | # Code is not reloaded between requests. 7 | config.enable_reloading = false 8 | 9 | # Eager load code on boot. This eager loads most of Rails and 10 | # your application in memory, allowing both threaded web servers 11 | # and those relying on copy on write to perform better. 12 | # Rake tasks automatically ignore this option for performance. 13 | config.eager_load = true 14 | 15 | # Full error reports are disabled and caching is turned on. 16 | config.consider_all_requests_local = false 17 | config.action_controller.perform_caching = true 18 | 19 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] 20 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). 21 | # config.require_master_key = true 22 | 23 | # Disable serving static files from the `/public` folder by default since 24 | # Apache or NGINX already handles this. 25 | config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? 26 | 27 | # Compress CSS using a preprocessor. 28 | # config.assets.css_compressor = :sass 29 | 30 | # Do not fallback to assets pipeline if a precompiled asset is missed. 31 | config.assets.compile = false 32 | 33 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 34 | # config.asset_host = "http://assets.example.com" 35 | 36 | # Specifies the header that your server uses for sending files. 37 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache 38 | # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX 39 | 40 | # Store uploaded files on the local file system (see config/storage.yml for options). 41 | config.active_storage.service = :local 42 | 43 | # Mount Action Cable outside main process or domain. 44 | # config.action_cable.mount_path = nil 45 | # config.action_cable.url = "wss://example.com/cable" 46 | # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] 47 | 48 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 49 | # config.force_ssl = true 50 | 51 | # Include generic and useful information about system operation, but avoid logging too much 52 | # information to avoid inadvertent exposure of personally identifiable information (PII). 53 | config.log_level = :info 54 | 55 | # Prepend all log lines with the following tags. 56 | config.log_tags = [ :request_id ] 57 | 58 | # Use a different cache store in production. 59 | # config.cache_store = :mem_cache_store 60 | 61 | # Use a real queuing backend for Active Job (and separate queues per environment). 62 | # config.active_job.queue_adapter = :resque 63 | # config.active_job.queue_name_prefix = "video_production" 64 | 65 | config.action_mailer.perform_caching = false 66 | 67 | # Ignore bad email addresses and do not raise email delivery errors. 68 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 69 | # config.action_mailer.raise_delivery_errors = false 70 | 71 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 72 | # the I18n.default_locale when a translation cannot be found). 73 | config.i18n.fallbacks = true 74 | 75 | # Don't log any deprecations. 76 | config.active_support.report_deprecations = false 77 | 78 | # Use default logging formatter so that PID and timestamp are not suppressed. 79 | config.log_formatter = ::Logger::Formatter.new 80 | 81 | # Use a different logger for distributed setups. 82 | # require "syslog/logger" 83 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") 84 | 85 | if ENV["RAILS_LOG_TO_STDOUT"].present? 86 | logger = ActiveSupport::Logger.new(STDOUT) 87 | logger.formatter = config.log_formatter 88 | config.logger = ActiveSupport::TaggedLogging.new(logger) 89 | end 90 | 91 | # Do not dump schema after migrations. 92 | config.active_record.dump_schema_after_migration = false 93 | end 94 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GIT 2 | remote: https://github.com/rails/rails.git 3 | revision: b8e09fc54ec369574ff34734514600428dbd8a2a 4 | branch: main 5 | specs: 6 | actioncable (7.1.0.alpha) 7 | actionpack (= 7.1.0.alpha) 8 | activesupport (= 7.1.0.alpha) 9 | nio4r (~> 2.0) 10 | websocket-driver (>= 0.6.1) 11 | zeitwerk (~> 2.6) 12 | actionmailbox (7.1.0.alpha) 13 | actionpack (= 7.1.0.alpha) 14 | activejob (= 7.1.0.alpha) 15 | activerecord (= 7.1.0.alpha) 16 | activestorage (= 7.1.0.alpha) 17 | activesupport (= 7.1.0.alpha) 18 | mail (>= 2.7.1) 19 | net-imap 20 | net-pop 21 | net-smtp 22 | actionmailer (7.1.0.alpha) 23 | actionpack (= 7.1.0.alpha) 24 | actionview (= 7.1.0.alpha) 25 | activejob (= 7.1.0.alpha) 26 | activesupport (= 7.1.0.alpha) 27 | mail (~> 2.5, >= 2.5.4) 28 | net-imap 29 | net-pop 30 | net-smtp 31 | rails-dom-testing (~> 2.0) 32 | actionpack (7.1.0.alpha) 33 | actionview (= 7.1.0.alpha) 34 | activesupport (= 7.1.0.alpha) 35 | rack (~> 2.0, >= 2.2.4) 36 | rack-test (>= 0.6.3) 37 | rails-dom-testing (~> 2.0) 38 | rails-html-sanitizer (~> 1.0, >= 1.2.0) 39 | actiontext (7.1.0.alpha) 40 | actionpack (= 7.1.0.alpha) 41 | activerecord (= 7.1.0.alpha) 42 | activestorage (= 7.1.0.alpha) 43 | activesupport (= 7.1.0.alpha) 44 | globalid (>= 0.6.0) 45 | nokogiri (>= 1.8.5) 46 | actionview (7.1.0.alpha) 47 | activesupport (= 7.1.0.alpha) 48 | builder (~> 3.1) 49 | erubi (~> 1.11) 50 | rails-dom-testing (~> 2.0) 51 | rails-html-sanitizer (~> 1.1, >= 1.2.0) 52 | activejob (7.1.0.alpha) 53 | activesupport (= 7.1.0.alpha) 54 | globalid (>= 0.3.6) 55 | activemodel (7.1.0.alpha) 56 | activesupport (= 7.1.0.alpha) 57 | activerecord (7.1.0.alpha) 58 | activemodel (= 7.1.0.alpha) 59 | activesupport (= 7.1.0.alpha) 60 | activestorage (7.1.0.alpha) 61 | actionpack (= 7.1.0.alpha) 62 | activejob (= 7.1.0.alpha) 63 | activerecord (= 7.1.0.alpha) 64 | activesupport (= 7.1.0.alpha) 65 | marcel (~> 1.0) 66 | mini_mime (>= 1.1.0) 67 | activesupport (7.1.0.alpha) 68 | concurrent-ruby (~> 1.0, >= 1.0.2) 69 | connection_pool (>= 2.2.5) 70 | i18n (>= 1.6, < 2) 71 | minitest (>= 5.1) 72 | tzinfo (~> 2.0) 73 | rails (7.1.0.alpha) 74 | actioncable (= 7.1.0.alpha) 75 | actionmailbox (= 7.1.0.alpha) 76 | actionmailer (= 7.1.0.alpha) 77 | actionpack (= 7.1.0.alpha) 78 | actiontext (= 7.1.0.alpha) 79 | actionview (= 7.1.0.alpha) 80 | activejob (= 7.1.0.alpha) 81 | activemodel (= 7.1.0.alpha) 82 | activerecord (= 7.1.0.alpha) 83 | activestorage (= 7.1.0.alpha) 84 | activesupport (= 7.1.0.alpha) 85 | bundler (>= 1.15.0) 86 | railties (= 7.1.0.alpha) 87 | railties (7.1.0.alpha) 88 | actionpack (= 7.1.0.alpha) 89 | activesupport (= 7.1.0.alpha) 90 | rake (>= 12.2) 91 | thor (~> 1.0) 92 | zeitwerk (~> 2.6) 93 | 94 | GEM 95 | remote: https://rubygems.org/ 96 | specs: 97 | addressable (2.8.1) 98 | public_suffix (>= 2.0.2, < 6.0) 99 | bindex (0.8.1) 100 | bootsnap (1.15.0) 101 | msgpack (~> 1.2) 102 | builder (3.2.4) 103 | capybara (3.38.0) 104 | addressable 105 | matrix 106 | mini_mime (>= 0.1.3) 107 | nokogiri (~> 1.8) 108 | rack (>= 1.6.0) 109 | rack-test (>= 0.6.3) 110 | regexp_parser (>= 1.5, < 3.0) 111 | xpath (~> 3.2) 112 | concurrent-ruby (1.1.10) 113 | connection_pool (2.3.0) 114 | crass (1.0.6) 115 | date (3.3.3) 116 | debug (1.7.1) 117 | error_highlight (0.5.1) 118 | erubi (1.12.0) 119 | globalid (1.0.0) 120 | activesupport (>= 5.0) 121 | i18n (1.12.0) 122 | concurrent-ruby (~> 1.0) 123 | importmap-rails (1.1.5) 124 | actionpack (>= 6.0.0) 125 | railties (>= 6.0.0) 126 | jbuilder (2.11.5) 127 | actionview (>= 5.0.0) 128 | activesupport (>= 5.0.0) 129 | loofah (2.19.1) 130 | crass (~> 1.0.2) 131 | nokogiri (>= 1.5.9) 132 | mail (2.8.0) 133 | mini_mime (>= 0.1.1) 134 | net-imap 135 | net-pop 136 | net-smtp 137 | marcel (1.0.2) 138 | matrix (0.4.2) 139 | mini_mime (1.1.2) 140 | mini_portile2 (2.8.1) 141 | minitest (5.17.0) 142 | msgpack (1.6.0) 143 | net-imap (0.3.4) 144 | date 145 | net-protocol 146 | net-pop (0.1.2) 147 | net-protocol 148 | net-protocol (0.2.1) 149 | timeout 150 | net-smtp (0.3.3) 151 | net-protocol 152 | nio4r (2.5.8) 153 | nokogiri (1.13.10) 154 | mini_portile2 (~> 2.8.0) 155 | racc (~> 1.4) 156 | pg (1.4.5) 157 | public_suffix (5.0.1) 158 | puma (6.0.2) 159 | nio4r (~> 2.0) 160 | racc (1.6.2) 161 | rack (2.2.5) 162 | rack-test (2.0.2) 163 | rack (>= 1.3) 164 | rails-dom-testing (2.0.3) 165 | activesupport (>= 4.2.0) 166 | nokogiri (>= 1.6) 167 | rails-html-sanitizer (1.4.4) 168 | loofah (~> 2.19, >= 2.19.1) 169 | rake (13.0.6) 170 | redis (5.0.5) 171 | redis-client (>= 0.9.0) 172 | redis-client (0.12.0) 173 | connection_pool 174 | regexp_parser (2.6.1) 175 | rexml (3.2.5) 176 | rubyzip (2.3.2) 177 | selenium-webdriver (4.7.1) 178 | rexml (~> 3.2, >= 3.2.5) 179 | rubyzip (>= 1.2.2, < 3.0) 180 | websocket (~> 1.0) 181 | sprockets (4.2.0) 182 | concurrent-ruby (~> 1.0) 183 | rack (>= 2.2.4, < 4) 184 | sprockets-rails (3.4.2) 185 | actionpack (>= 5.2) 186 | activesupport (>= 5.2) 187 | sprockets (>= 3.0.0) 188 | stimulus-rails (1.2.1) 189 | railties (>= 6.0.0) 190 | thor (1.2.1) 191 | timeout (0.3.1) 192 | turbo-rails (1.3.2) 193 | actionpack (>= 6.0.0) 194 | activejob (>= 6.0.0) 195 | railties (>= 6.0.0) 196 | tzinfo (2.0.5) 197 | concurrent-ruby (~> 1.0) 198 | web-console (4.2.0) 199 | actionview (>= 6.0.0) 200 | activemodel (>= 6.0.0) 201 | bindex (>= 0.4.0) 202 | railties (>= 6.0.0) 203 | webdrivers (5.2.0) 204 | nokogiri (~> 1.6) 205 | rubyzip (>= 1.3.0) 206 | selenium-webdriver (~> 4.0) 207 | websocket (1.2.9) 208 | websocket-driver (0.7.5) 209 | websocket-extensions (>= 0.1.0) 210 | websocket-extensions (0.1.5) 211 | xpath (3.2.0) 212 | nokogiri (~> 1.8) 213 | zeitwerk (2.6.6) 214 | 215 | PLATFORMS 216 | x86_64-linux 217 | 218 | DEPENDENCIES 219 | bootsnap 220 | capybara 221 | debug 222 | error_highlight (>= 0.4.0) 223 | importmap-rails 224 | jbuilder 225 | pg (~> 1.1) 226 | puma (>= 5.0) 227 | rails! 228 | redis (>= 4.0.1) 229 | selenium-webdriver 230 | sprockets-rails 231 | stimulus-rails 232 | turbo-rails 233 | tzinfo-data 234 | web-console 235 | webdrivers 236 | 237 | RUBY VERSION 238 | ruby 3.2.0p0 239 | 240 | BUNDLED WITH 241 | 2.4.1 242 | --------------------------------------------------------------------------------