Rails: How to get URL params without routing parameters (or vice versa)
Rails merges query string, request body, and routing data in params; request.query_parameters and request.path_parameters separate URL values from route data.
Rails Env Widget
A small helper adds a dismissible on-screen badge showing the current Rails environment to prevent confusion between development, test, and production.
Cucumber step to pick a datetime in Rails' horrible datetime_select
datetime_select creates a clumsy date and time chooser in Rails; a visual picker is usually better, but a Cucumber step can still drive it.
Rails index route for resources named after uncountable substantives
Uncountable Rails resources break normal route helpers and form handling. resource can still expose the index action through a special _index_path helper.
dusen and edge_rider gems no longer depend on Rails
dusen 0.4.8 and edge_rider 0.2.3 no longer require Rails, while still depending on ActiveRecord, making them usable with Sinatra and other non-Rails apps.
Rails: Invoking a view helper from the console
Call view helpers from the Rails console via helper or an ActionView::Base instance when a helper depends on templates.
Rails 4.1+ automatically detects the :inverse_of an association
Rails 4.1 infers association inverses automatically, but failures are silent and extra options can block detection. Setting :inverse_of manually remains safer.
OR-ing query conditions on Rails 4 and 3.2
Rails 4 and 3.2 lack ActiveRecord::Relation#or for combining query conditions; activerecord_any_of provides any_of and none_of for cleaner disjunctive filters.
Rails 3.1 error message: Could not find a JavaScript runtime
Fresh Rails 3.1 apps can fail on boot when ExecJS cannot locate a JavaScript runtime, and adding a runtime gem to the Gemfile removes the error.
Subscribe to Rails security mailing list without Google account
Subscribe to the Ruby on Rails security mailing list without a Google account by using a direct boxsubscribe URL instead of the web interface.
How to enable Rails' file_fixture helper in FactoryBot
FactoryBot factories do not get Rails' file_fixture helper by default; including RSpec Rails file fixture support makes file_fixture available and sets the fixture path.
How to disable Rails raising errors on pending migrations in development
Rails 4 can block page loads in development when migrations are pending, which interrupts experimenting with a new migration. Setting config.active_record.migration_error to false disables the check.
Fix Rubygems warning: Gem.source_index is deprecated, use Specification
Rubygems updates can flood legacy Rails apps with Gem::SourceIndex deprecation warnings. SlimGems or upgrading Rails 2.3.11 to 2.3.12+ reduces the noise.
Use non-ASCII characters on IRB and Rails consoles with RVM and Mac OS X
Missing readline support prevents non-ASCII input in IRB or Rails consoles on Mac with RVM; reinstalling Ruby with readline enables 8-bit characters.
Retrieve the SQL query a scope would produce in ActiveRecord
Get the SQL generated by an ActiveRecord scope without executing it; Rails 3 uses to_sql, while Rails 2 needs a backport or construct_finder_sql.
Use the Ruby debugger on Rails 2 script/runner scripts
Rails 3+ script/runner debugging needs rdebug because --debugger is gone; Ruby-debug must be available and required to enter the debugger from a script.
Fix error: rails console - no such file to load -- readline
rails console fails with no such file to load -- readline when Ruby was built without readline support. Reinstalling Ruby with the readline development library available restores console input.
Passenger 5/6 requires a config.ru file to run Rails 2.3 projects
Rails 2.3 apps need a config.ru file for Passenger 5+; without it, nginx or Apache may return 403 errors because the app is not detected.
Using mime types with send_file
Rails file downloads need correct MIME mappings so browsers can open attachments directly instead of forcing a save dialog.
Upgrade from Rails 2.3.8 to Rails 2.3.10
Rails 2.3.8 to 2.3.10 upgrades can reduce bugs and security risk in older applications.
Upgrade from Rails 2.3.10 to Rails 2.3.11
A Rails 2.3.10 to 2.3.11 upgrade can reduce maintenance risk and keep an older application on a supported patch level.
Rails has a built-in slug generator
Ruby on Rails includes parameterize for turning text into URL-friendly slugs, normalizing spaces, punctuation, and accented characters.
Installing old versions of mysql2 on Ubuntu 20.04+
Legacy mysql2 gem versions 0.2.x and 0.3.x fail on Ubuntu 20.04+ for older Rails apps; a fork and libmariadb-dev can restore compatibility.
Minified JavaScript and CSS
Production assets should be minified for faster delivery and smaller payloads. Rails 3.1+ handles this through the asset pipeline; older Rails versions need compressed JavaScript libraries.