Rendering 404s for missing images via Rails routes
Missing image requests in development can hit Rails controllers and slow pages with many broken references. A route can return an instant empty 404 for absent JPG, PNG, and GIF files.
Upgrading a Rails 3.2 application to Ruby 2.1 is really easy
Ruby 1.8.7 to 2.1.2 upgrades are usually straightforward for Rails 3.2 apps, with a few compatibility fixes for load paths, debugging, removed gems, and UTF-8 defaults.
Zeus promises to make rails development faster
Rails app boot and test startup become slow as gems grow; Zeus preloads the app so console, server, generate, and specs run in under a second.
AngularJS directive to format a text with paragraphs and new lines
Plain text in AngularJS can be rendered as paragraphs and line breaks while escaping HTML fragments, similar to Rails simple_format.
How to get the hostname of the current machine in Rails or a Ruby script
Socket.gethostname returns the current machine’s hostname in Rails or Ruby; hostname is a fallback on Unix-like systems, but may include trailing newline or FQDN.
Custom loggers in Ruby and Rails
Ruby and Rails logging to files or stdout can be timestamped, thread-safe, and formatted consistently; Logger also supports full backtraces for errors.
See which Rails applications are being served by your Passenger
passenger-memory-stats lists Passenger processes with application directories and memory usage, making it easy to identify which Rails apps are currently served.
Creating the inverse of a Rails migration
Reverting an old Rails change can reuse the original migration’s up and down logic instead of copying SQL, but only for simple cases.
Use Sass without Rails
Generate CSS from Sass on a static site without Rails by watching source files and rewriting stylesheets automatically.
When does Webpacker compile?
Webpacker compiles assets on demand in Rails, which can freeze helpers and slow page reloads when no dev server is running.
Controller specs do not persist the Rails session across requests of the same spec
Controller specs reset the Rails session on every request, so data written earlier disappears between calls. Stubbing controller.session with a shared TestSession preserves state for testing.
Caveat when using Rails' new "strict locals" feature
Rails 7.1 strict locals can make unrelated ArgumentErrors look like render-call failures, obscuring the real source of an error in a partial.
Rendering a custom 404 page in Rails 2
Custom handling for missing records in Rails 2 can render a branded 404 page instead of a generic exception when ActiveRecord::RecordNotFound occurs.
MongoMapper for Rails 2 on Ruby 1.9
MongoMapper support for Rails 2.3.x on Ruby 1.9 via a forked gem branch; compatible with Ruby 1.8.7, REE, and Ruby 1.9.3.
Rails 4 Engines - TechRabbit
A modular Rails architecture can balance the simplicity of a single app with the separation of multiple services. Rails engines provide shared structure without the overhead of a full service-oriented setup.
Security fixes for Rails 2.3
A security issue in Rails 2.3 required a patch after the branch stopped being maintained, so a minimal fork keeps legacy apps on a fixed version.
Rails 2.3.x sometimes renders localized views with the wrong content type
Rails 2.3.5 can send an invalid Response content-type for localized view templates, causing browsers to receive de.html instead of text/html.
PostgreSQL vs. Rails migration: How to change columns from string to integer
Changing a Rails column from string to integer fails on PostgreSQL without an explicit USING cast; non-numeric values can convert unpredictably.
Bugfix: Rails 2 does not find an association when it is named with a string instead of a symbol
Rails 2 can miss an association declared with a string name, causing "association not found" errors; using a symbol avoids the lookup bug.
ActionMailer sometimes breaks e-mails with multiple recipients in Rails 2
Rails 2 mail sending can produce malformed headers for multiple recipients because a buggy TMail version inserts a blank line. A maintained fork fixes the issue when no MTA repairs it.
Let a Rails 3 application make a request to itself
Rails 3 can issue internal HTTP requests through the Rack interface, useful for Cucumber features and testing app responses without a browser.
Exporting to Excel from Rails without a gem
Generate Excel spreadsheets from Rails views without a gem, using .xlsx.erb templates and avoiding spreadsheet gem limits on performance and styling.
shoulda-matcher methods not found in Rails 4.1
allow_value and other shoulda-matchers methods can disappear under Rails 4.1 with Spring, causing NoMethodError despite the gem being listed.
Fix warning: Cucumber-rails required outside of env.rb
Bundler 1.1 can trigger a misleading Cucumber warning during test runs; disabling automatic loading for cucumber-rails removes it without moving the gem into a test group.