New Firefox and gem versions for our Selenium testing environment (Ubuntu 14.04+)
Firefox 5.0.1 no longer runs on Ubuntu 14.04, so Selenium test setups need browser and gem updates to keep Rails 2.3 and Cucumber projects working.
Use ActiveSupport autoloading outside of Rails
Enable Rails-style autoloading in a plain Ruby setup by adding load paths to ActiveSupport::Dependencies.autoload_paths.
Rails: Running specific migrations
Targeted database migrations in Rails use STEP and VERSION to run, redo, rollback, or revert a chosen migration without processing the full history.
Do not pass params directly into url_for or URL helpers
Passing untrusted parameters into url_for or _url helpers can create open redirect vulnerabilities and send users to attacker-controlled hosts.
How to: Use Ace editor in a Webpack project
Ace editor adds syntax highlighting and auto-indenting for in-browser code editing, with a working brace setup for Ruby on Rails Webpacker and Webpack 2.
Minidusen: Low-tech record filtering with LIKE queries
Lightweight record filtering for Rails replaces FULLTEXT indexing with LIKE queries and keeps search compatible with MySQL and PostgreSQL.
Cronjobs: "Craken" is dead, long live "Whenever"
Old cronjob management with craken no longer works on Rails 3.2+, so whenever becomes the replacement for deploying rake tasks into cron.
When Rails does not recognize Rake tasks in lib/tasks
Rake tasks in lib/tasks are ignored when the filename ends in .rb; Rails and Rake load them only from .rake files.
MySQL 5.7.5 enables `ONLY_FULL_GROUP_BY` mode per default
ONLY_FULL_GROUP_BY in MySQL 5.7 rejects queries that select non-grouped columns, preventing nondeterministic results and breaking some Rails scopes.
Use a Bash function to alias the rake command to Spring binstubs or "bundle exec" fallback
A Bash function can route rake to bin/rake when Spring binstubs exist, otherwise to bundle exec rake, speeding Rails 4.1+ and avoiding version conflicts on older apps.
Rails always tries to use a layout with the same name as your controller
Rails automatically applies a same-named layout for a controller, which can create surprising view behavior when an unintended template is picked up.
Active Record and PostgreSQL — Ruby on Rails Guides
PostgreSQL offers native column types such as json and arrays that simplify data modeling in Rails and can replace awkward workarounds from MySQL.
Auto-coerced virtual attributes with Virtus
Virtual ActiveRecord attributes can lose Rails-style type casting, causing string values, validation roundtrip bugs, and broken select boxes. Virtus restores coercion for non-persistent fields.
Edge Rider: Power tools for ActiveRecord scopes
Edge Rider adds utility methods and compatibility patches for working with ActiveRecord scopes across Rails versions, reducing breakage from changing scope APIs.
How to recognize CVE-2019-5418
Path traversal probes in Rails request parameters can indicate attempts to exploit CVE-2019-5418. Fixed releases block the vulnerability.
Nested ActiveRecord transaction pitfalls
Nested ActiveRecord transactions can hide inner ActiveRecord::Rollback exceptions or fire after_commit callbacks too early, depending on joinable: false and requires_new.
NoMethodError: undefined method `cache' for Gem:Module
Rails 2.3 tests can fail with NoMethodError: undefined method 'cache' for Gem:Module when used with newer RubyGems; downgrading RubyGems restores generator lookup behavior.
Using Solr with Sunspot
Running Solr with Sunspot adds Rails search, but requires local setup, reindexing, error handling, and production configuration for a separate Solr server.
ActionMailer: How to send a test mail directly from the console
Rails console debugging for mail delivery failures, with ActionMailer settings inspection and a direct test message to verify SMTP and spam score.
A few hints when upgrading to Ruby 1.9
Ruby 1.9 upgrades in Rails apps often fail because of gem incompatibilities, lambda arity issues, and encoding mismatches between files, strings, and databases.
Resque: Clearance authentication for dashboard
Resque dashboard access can bypass ApplicationController filters in Rails 3, so a Rack middleware can protect it with Clearance and a remember token.
Deal with certain travis CI failures
Travis CI builds can break after Ubuntu image changes, causing PostgreSQL, MySQL, and Rails test failures. Pinning dist: trusty keeps the older environment until the setup is updated.
Upgrading Ruby from 1.8.7 to 2.3.5
Ruby 2.3.5 migration from 1.8.7 needs gem updates, syntax fixes, and test adjustments to resolve compatibility errors across Rails apps.
Fix warning: No secret option provided to Rack::Session::Cookie
Rails with recent Rack versions can emit a session cookie security warning when no secret is configured; locking Rack to 1.4.1 works around the issue.