Load order of the environment
Rails environment code loads in a fixed boot order, affecting which settings and constants can override others. Knowing the initialization sequence prevents surprises when adding configuration or app code.
Ensure passing Jasmine specs from your Ruby E2E tests
Run Jasmine specs through Rails E2E tests to catch JavaScript failures in regular test runs and verify the runner finishes with all specs passing.
Rails: Adding a unique constraint for a has_one association might be a good default
A unique index on a has_one foreign key lets the database enforce 1:1 relationships and fail fast when application logic creates duplicate rows.
Rails cache connection settings
Redis cache connections in Rails can be tuned with custom timeouts, reconnect behavior, and error handling to avoid slow cache operations and missed connection failures.
Taming icon fonts for use in Rails views
Icon fonts are awkward to use directly in Rails views; helpers and Sass mixins make icon classes, labels, and styling easier to manage.
Logging multiple lines in Rails without making filtering your logs difficult
Multi-line Rails logs are hard to filter because only the first line gets tagged. Logging each line separately keeps request IDs and timestamps on every line.
routing-filter is broken with Rails 7.1
routing-filter stops working in Rails 7.1 because find_routes now yields lazily, leaving URL segment filters unapplied and routes unrecognized.
Heads up: RSpec-Mocks' #stub_const will define intermediate modules that have not been loaded yet
stub_const can create an unloaded intermediate module and break tests with unexpected method errors. Using the class constant in the path lets Rails autoload the class first.
RSpec: Inferring spec type from file location
RSpec Rails can infer spec behavior from file location, removing manual type tags and enabling request helpers like get and post where appropriate.
ActiveRecord: Cleaning up your database with ignored_colums
Unused database columns confuse teams and can linger safely while legacy access is phased out. ignored_columns removes Rails accessors and helps flag fields for later removal.
Capistrano task to edit staging / production credentials
Editing Rails credentials for staging or production requires server-only secret keys; a Capistrano task opens the decrypted file without copying keys to a dev machine.
Rails: Pluck across associated tables
pluck can fetch values from joined tables in one query, returning columns from associated records without loading full Active Record objects.
Rails: Example on how to extract domain independent code from the `app/models` folder to the `lib/` folder
Move API-client code out of app/models into lib/ to separate domain logic from reusable infrastructure and keep Rails code more maintainable.
Rails: How to stub the env in Rails 7+
Rails 7.1 adds Rails.env.local?; stubbing Rails.env with a plain string can fail, while ActiveSupport::EnvironmentInquirer keeps environment checks working.
A simple example with a GIN index in Rails for optimizing a ILIKE query
ILIKE searches in PostgreSQL can be slow without trigram indexing; a GIN index with pg_trgm can replace sequential scans with bitmap index scans.
How to reload a belongs_to association
Reload a single-record Rails association without reloading the whole parent object; Rails 5+ uses reload_<association>, older versions accept association(true).
Three quick Rails console tips
Rails console sessions can exercise routes, requests, and helpers without running the full app in a browser.
CI Template for GitHub Actions
GitHub Actions CI template for Rails apps with parallel RSpec, RuboCop, ESLint, license checks, security scanning, and merged coverage reports.
Webpack(er): A primer
Webpacker integrates webpack with Rails to bundle JavaScript, stylesheets, images, and other assets, with Yarn managing dependencies and loaders handling non-JavaScript files.
A simpler default controller implementation
Rails controllers can stay short, testable and authorization-friendly by using a minimal shared blueprint for CRUD, strong params, scopes and optional HTTP caching.
tel_to Rails helper for linking phone numbers
tel: links let smartphone users call phone numbers from web pages, and a small Rails helper turns human-readable numbers into clean clickable dial links.
Searchkick: async reindexing fails for rails 7 with redis 4
Searchkick async reindexing can break on Rails 7.1 with Redis 4 because ActiveSupport#with conflicts with the Redis API, causing undefined method 'call' for nil.
Rails: Comparison of assignable_values and Active Record enum types
Rails enum attributes store states as integers or database enums, with validation and generated scopes; assignable_values still offers conditional rules, associations, and array support.
Rails: Restrict deletion of a parent record using scoped associations
Block parent deletion when specific child-record conditions exist by combining scoped has_many associations with dependent: :restrict_with_error and ordered callbacks.