Resources

100 Ruby on Rails resources for developers

The Ruby on Rails ecosystem has evolved into 'The One Person Framework' with the release of Rails 8, prioritizing self-hosting via Kamal and removing heavy dependencies like Redis for job processing. This resource guide focuses on the practical implementation of Rails 8 defaults, Hotwire patterns for modern frontends, and the integration of LLMs into Active Job pipelines.

Modern Frontend Development with Hotwire

  1. 1

    Turbo Frames for Partial Page Updates

    beginnerhigh

    Isolate page segments to update content without a full reload. Use the 'src' attribute for lazy-loading heavy components like dashboards.

  2. 2

    Turbo Streams over WebSockets

    intermediatehigh

    Broadcast model changes to all connected users using ActionCable. Use 'broadcast_replace_to' in models to trigger UI updates automatically.

  3. 3

    StimulusJS State Management

    beginnerstandard

    Use Stimulus Values and Classes APIs to manage toggle states and CSS transitions without writing custom event listeners.

  4. 4

    ViewComponent for UI Encapsulation

    intermediatemedium

    Move complex logic out of partials and into Ruby classes. Use GitHub's ViewComponent library for unit-testable UI units.

  5. 5

    Turbo Morphing

    intermediatehigh

    Enable 'data-turbo-action="morph"' for smoother page transitions that preserve scroll position and input focus during updates.

  6. 6

    Tailwind CSS JIT Integration

    beginnerstandard

    Configure tailwind.config.js to scan .rb and .erb files. Use the 'tailwindcss-rails' gem to manage the standalone CLI.

  7. 7

    Phlex for Ruby-Based Views

    advancedmedium

    An alternative to ERB that uses pure Ruby objects for views, offering significant performance gains for high-traffic pages.

  8. 8

    Stimulus Use Hooks

    intermediatestandard

    Implement 'stimulus-use' for common patterns like click-outside, intersection observers, and debouncing in controllers.

  9. 9

    Custom Turbo Stream Actions

    advancedmedium

    Extend Turbo to handle non-standard DOM operations like triggering client-side logging or updating browser history.

  10. 10

    Importmap-rails Management

    beginnerstandard

    Manage JavaScript dependencies without Node.js. Use 'bin/importmap pin' to add libraries directly from CDNs like JSPM.

Rails 8 Infrastructure and Deployment

  1. 1

    Kamal Deployment Configuration

    intermediatehigh

    Deploy Rails applications to any VPS using Docker. Configure 'config/deploy.yml' with server IPs and environment secrets.

  2. 2

    Solid Queue for Background Jobs

    beginnerhigh

    The new Rails 8 default job runner. Move away from Redis and use your PostgreSQL or MySQL database for persistence.

  3. 3

    Solid Cache for Database Caching

    beginnermedium

    Store cache fragments in the database instead of RAM. Ideal for keeping larger amounts of data cached at a lower cost.

  4. 4

    Thruster HTTP/2 Proxy

    intermediatestandard

    Use the Thruster sidecar with Kamal to provide HTTP/2 support and asset compression without a complex Nginx setup.

  5. 5

    Mission Control Jobs

    beginnermedium

    Install the 'mission_control-jobs' engine to get a built-in dashboard for monitoring and retrying Solid Queue jobs.

  6. 6

    Prop: Rate Limiting

    intermediatestandard

    Implement the 'prop' gem to prevent brute force attacks and API abuse by defining throttle strategies in an initializer.

  7. 7

    Healthcheck Endpoint Configuration

    beginnerstandard

    Configure 'up' endpoints for Kamal or Kubernetes to monitor DB, Redis, and Job runner availability via 'rails-healthcheck'.

  8. 8

    Zero-Downtime DB Migrations

    advancedhigh

    Use the 'strong_migrations' gem to detect and block unsafe operations like adding columns with defaults on large tables.

  9. 9

    Kamal Accessory Management

    intermediatemedium

    Define databases and search engines as 'accessories' in deploy.yml to manage their lifecycle alongside the Rails app.

  10. 10

    Multi-Environment Kamal Deploys

    intermediatestandard

    Utilize Kamal's destination feature to manage staging and production environments within a single configuration file.

AI Integration and Data Patterns

  1. 1

    Langchainrb Orchestration

    intermediatehigh

    Use the 'langchainrb' gem to build RAG (Retrieval Augmented Generation) pipelines within Rails service objects.

  2. 2

    Pgvector for Semantic Search

    advancedhigh

    Install the 'pgvector' extension on PostgreSQL and use the 'neighbor' gem to perform vector similarity searches on records.

  3. 3

    Streaming LLM Responses

    advancedhigh

    Use ActionController::Live to stream OpenAI or Anthropic responses to the frontend as they are generated.

  4. 4

    Active Job for LLM Callbacks

    intermediatestandard

    Offload LLM API calls to background jobs to avoid blocking the web thread. Use Solid Queue for reliable retries on rate limits.

  5. 5

    Structured Data with JSON Schema

    intermediatemedium

    Enforce LLM output formats by passing JSON schemas to the OpenAI API and parsing responses into Active Model objects.

  6. 6

    Embedding Generation on Save

    intermediatemedium

    Use ActiveRecord callbacks to automatically update vector embeddings in a background job whenever a record is updated.

  7. 7

    Token Usage Tracking

    beginnerstandard

    Implement a 'Usage' model to track tokens consumed per user or per request to manage LLM costs and billing.

  8. 8

    Prompt Versioning

    beginnermedium

    Store system prompts in YAML files or a dedicated database table to version and A/B test prompt performance.

  9. 9

    Function Calling with Rails Tools

    advancedhigh

    Expose Rails service objects as tools for LLMs, allowing models to query your database or trigger actions via API.

  10. 10

    Local LLM Development with Ollama

    beginnerstandard

    Connect your Rails development environment to Ollama to test AI features locally without incurring API costs.