text = $.*
you can try it at https://pegjs.org/online :) add_index :tags, :name
adding a null constraint: change_column :tags, :name, :string, null: false
validates :name, presence: true # for proper validations
https://github.com/localhostdotdev/bug/commit/3765237008c36c... rails g model Post published_at:datetime title content:text
rails g model Comment post:references author published_at:datetime content:text
rails g model Tag name
rails g model PostTag post:references tag:references
class Post < ApplicationRecord
has_many :comments
has_many :post_tags
has_many :tags, through: :post_tags
end
class Tag < ApplicationRecord
has_many :post_tags
has_many :posts, through: :post_tags
end
from there it's just regular rails: Tag.find_by(name: "something").posts
Post.joins(:tags).where(tags: { name: "something" })
Tag.create(name: "something")
Post.create(...)
Tag.first.posts << Post.all.sample(2)
made a little repo if people want to play with it: https://github.com/localhostdotdev/bug/tree/orm-or-not-orm