Template of a custom feed generator service for the Bluesky network in Ruby

added missing string length validations

Changed files
+22 -3
app
models
db
+4
app/models/post.rb
··· 4 4 class Post < ActiveRecord::Base 5 5 validates_presence_of :repo, :time, :data, :rkey 6 6 validates :text, length: { minimum: 0, allow_nil: false } 7 + validates_length_of :repo, maximum: 60 8 + validates_length_of :rkey, maximum: 16 9 + validates_length_of :text, maximum: 1000 10 + validates_length_of :data, maximum: 10000 7 11 8 12 has_many :feed_posts, dependent: :destroy 9 13
+15
db/migrate/20241017135717_add_missing_limits.rb
··· 1 + class AddMissingLimits < ActiveRecord::Migration[6.1] 2 + def up 3 + change_table :posts do |t| 4 + t.change :repo, :string, limit: 60, null: false 5 + t.change :rkey, :string, limit: 16, null: false 6 + end 7 + end 8 + 9 + def down 10 + change_table :posts do |t| 11 + t.change :repo, :string, null: false 12 + t.change :rkey, :string, null: false 13 + end 14 + end 15 + end
+3 -3
db/schema.rb
··· 10 10 # 11 11 # It's strongly recommended that you check this file into your version control system. 12 12 13 - ActiveRecord::Schema[8.0].define(version: 2024_06_04_130301) do 13 + ActiveRecord::Schema[8.0].define(version: 2024_10_17_135717) do 14 14 create_table "feed_posts", force: :cascade do |t| 15 15 t.integer "feed_id", null: false 16 16 t.integer "post_id", null: false ··· 19 19 end 20 20 21 21 create_table "posts", force: :cascade do |t| 22 - t.string "repo", null: false 22 + t.string "repo", limit: 60, null: false 23 23 t.datetime "time", precision: nil, null: false 24 24 t.string "text", null: false 25 25 t.text "data", null: false 26 - t.string "rkey", null: false 26 + t.string "rkey", limit: 16, null: false 27 27 t.index ["repo", "time"], name: "index_posts_on_repo_and_time" 28 28 t.index ["rkey"], name: "index_posts_on_rkey" 29 29 t.index ["time"], name: "index_posts_on_time"