How to disable cookies in cucumber tests
Capybara has no built-in switch for disabling cookies in browser tests; a small Rack middleware can strip request cookies so scenarios can verify sign-in failures without them.
Install RubyMine under Ubuntu
RubyMine on Ubuntu can be installed as a snap with automatic updates or set up manually from the legacy archive. Configuration stays in ~/.config/JetBrains/RubyMine<version> with classic confinement.
Always show all form errors during development
Forms can fail validation without visible feedback when the offending field has no input. A development-only error box keeps all form errors visible without leaving debug markup behind.
Checking database size by row count
Quickly gauge which database tables are growing unnoticed by checking approximate row counts in PostgreSQL or MySQL.
Caution: `.includes` can make `.ids` non-unique.
includes can duplicate primary keys in ids when loading associated records, causing unexpected non-unique results; preload keeps the ids list stable.
How to fix gsub on SafeBuffer objects
html_safe strings lose $1 and other match variables inside gsub blocks. A SafeBuffer override can restore access to capture groups during replacements.
How to remove properties of ActiveRecord scopes
unscope removes selected ActiveRecord scope constraints such as where and order, while unscoped returns an entirely unconstrained relation.
Bulk-change multiple table rows in a migration
Multiple column changes in a migration can trigger repeated SQL and slow large tables; change_table can bundle them into one ALTER TABLE statement.
Render Sass stylesheets dynamically
Serve CSS at request time from Sass templates while keeping asset_path, imports, and injected theme colors available. Useful when styles need dynamic values without ERB preprocessing.
Upgrading from Capistrano 2 to 3
Capistrano 3 replaces the old DSL with Rake and SSHKit, changing task syntax, hooks, server settings, and file layout during migration from Capistrano 2.
Threads and processes in a Capybara/Selenium session
Capybara/Selenium tests involve a test process, a server thread and a browser process, so blocking, stale time, and uncommitted transactions can cause seemingly impossible failures.
Fix „command failed: /usr/bin/wkhtmltopdf ...“ using PDFKit middleware
PDF generation via wkhtmltopdf can fail on Passenger when the wrong binary is used or routing errors trigger deadlocks. Pointing PDFKit to a working local executable avoids the command failure.
Carrierwave: Using a nested directory structure for file system performance
Large CarrierWave stores can overload a single directory with too many entries, slowing navigation and filesystem operations. Splitting record IDs into nested folders keeps directories manageable.
PostgreSQL: How to show table sizes
Large PostgreSQL databases can hide tables that consume most disk space. pg_total_relation_size and pg_size_pretty help identify the biggest relations quickly.
Geordi 1.3 released
Geordi 1.3 adds Cucumber support with @solo handling, Capistrano 2/3 deployment fixes, and updated Firefox setup for selenium testing.
Copy to clipboard without flash (clipboard.js)
Flash-free copy-to-clipboard handling with clipboard.js, including success and error callbacks, text selection feedback, and support for text fields or data attributes.
Using RSpec stubs and mocks in Cucumber
Cucumber can use RSpec doubles instead of Mocha; loading the integration in env.rb keeps stubs and mocks available after other After hooks.
How to fix: "rake db:rollback" does not work
rake db:rollback can do nothing when the latest migrated version has no matching migration file, often after switching branches or deleting a migration.
Test redirects to an external URL with Cucumber/Capybara
External redirects are awkward to test with Cucumber and Capybara: Rack::Test ignores the host, while Selenium follows it. Controller specs or an observable redirect make the target URL verifiable.
Careful when writing to has_many :through associations
has_many :through associations can lose or duplicate records when written to, especially with nested forms and loaded associations. Treat them as read-only or build the join records directly.
How to inspect controller filter chains in specs
Inspecting callback chains in controller specs helps verify before- and after-action behavior, especially when tests need to confirm filter order or presence.
How to use Haml in your helpers
Rendering helper output with content_tag can get clumsy; Haml::Engine lets helper methods build HTML fragments more readably, with access to other helpers and locals.
Split an array into groups
Ruby arrays can be split into fixed-size groups or a chosen number of groups with ActiveSupport, padding or omitting leftovers as needed.
Postgres: How to force database sessions to terminate
PG::ObjectInUse blocks dropping or resetting a PostgreSQL database when other sessions stay connected. Find the backend PID and terminate the process when needed.