I think you have looked at the tutorial from Mr. Heinemeier Hansson at least once or twice and have a similar setup.
application
- ruby 3.2.2
- rails 7.1.3.2
- postgresql 15
server
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "rdbg", | |
"name": "Debug Rails", | |
"request": "launch", | |
"cwd": "${workspaceRoot}", | |
"script": "bin/rails server", | |
"args": [], |
# frozen_string_literal: true | |
# https://github.com/rails/rails/blob/main/guides/bug_report_templates/generic_gem.rb | |
require "bundler/inline" | |
gemfile(true) do | |
source "https://rubygems.org" | |
git_source(:github) { |repo| "https://github.com/#{repo}.git" } |
# frozen_string_literal: true | |
# Rails: 私の好きなコード(5)永続化とロジックを絶妙にブレンドするActive Record(翻訳) | |
# https://techracho.bpsinc.jp/hachi8833/2023_04_18/127103 | |
# Topic | |
# has_many :entry_creators, -> { distinct }, through: :entries, source: :creator | |
# | |
# https://github.com/rails/rails/blob/main/guides/bug_report_templates/active_record_gem.rb | |
# Rename: Post(posts) => Topic(topics), Comment(comments) => Entry(entries) | |
# New: Creator(creators) |
# frozen_string_literal: true | |
# Rails: 私の好きなコード(5)永続化とロジックを絶妙にブレンドするActive Record(翻訳) | |
# https://techracho.bpsinc.jp/hachi8833/2023_04_18/127103 | |
# Topic | |
# has_many :blocked_trackers, through: :entries, class_name: "Entry::BlockedTracker" | |
# | |
# https://github.com/rails/rails/blob/main/guides/bug_report_templates/active_record_gem.rb | |
# Rename: Post(posts) => Topic(topics), Comment(comments) => Entry(entries) | |
# New: Entry::BlockedTracker(entry_blocked_trackers) |
# bundle add bcrypt | |
# rails g scaffold Account email password_digestx | |
# rails db:migrate | |
class Account < ApplicationRecord | |
has_secure_password validations: false | |
validate do |record| | |
record.errors.add(:password, :blank) unless record.password_digest.present? | |
end | |
validates :password, format: { with: /\A[a-z0-9]+\z/i }, length: { in: 8..30 }, on: :create, unless: -> { password_digest.blank? } | |
validates :password, format: { with: /\A[a-z0-9]+\z/i }, length: { in: 8..30 }, on: :update, allow_nil: true |
web: bin/rails server -p 3000 | |
redis: redis-server /usr/local/etc/redis.conf | |
worker: bundle exec sidekiq -q mailers |
macOS 11.6 | |
rails 7.0.0 | |
brew install vips | |
brew install redis | |
redis-server /usr/local/etc/redis.conf | |
00:00 Scaffolding | |
rails new demo | |
cd demo |
mkdir app/views/shared
touch app/views/shared/_turbo_stream_error_explanation.erb
bin/rails g stimulus reset_form
<% form_data = { controller: "reset-form", action: "turbo:submit-end->reset-form#reset" }%>
<%= form_with model: @message, data: form_data do |form| %>
<%= form.text_field :body %>
<%= form.submit %>
<% end %>