Will Rails 3 obstruct plugin innovation? - Gem Session

Where there was once a consistent API to manipulate and hook into the lifecycle of a persistent object, plugins must now perform very careful checks whether an object supports more advanced traits like transactions, observers or dirty attribute tracking.

travisliu/traim: Resource-oriented microframework for RESTful APIs

Build a RESTful API for ActiveRecord models with very little code. Traim emits a Rack application that can run standalone or inside Rails, but the 1:1 resource model can become limiting.

Careful when using Time objects for generating ETags

Time values in ETag generation can lose millisecond precision, causing stale cache hits and flaky tests. Convert them to strings or numbers before combining cache keys.

Be very careful with 301 and 308 redirects

301 and 308 redirects can be cached by browsers indefinitely without cache control, making later changes impossible unless users clear their cache.

Don't use Ruby 1.9.2

Ruby 1.9.2 loads files very slowly, making Rails startup and test runs painfully long. Upgrading to 1.9.3 removes the bottleneck.

Generate a path or URL string from an array of route components

polymorphic_path and polymorphic_url build route strings from arrays of model objects or route components, including :new and :edit prefixes. Nested Active Record namespacing can fail to resolve the correct route.

Using Passenger for development (with optional SSL)

Run a Rails app locally with Apache and Passenger for development, including optional HTTPS using a self-signed certificate.

Sending raw JSON data to a member action in a controller spec

Rails 4 controller specs can send raw JSON in a member action request by passing the JSON body before the route parameters.

Preventing users from uploading malicious content

Uploaded HTML or SVG can execute JavaScript and steal session cookies; safer uploads rely on extension allowlists, strict CSP, attachment disposition, or octet-stream delivery.

Project management best practices: Technical debt summary

Prioritizing refactoring and upgrade work is harder in larger projects; a maintained technical-debt summary helps compare effort, customer value, and developer value.

Passenger ignores RailsEnv directive for Rails 3 applications

You might find that your Passenger ignores all RailsSomething directives in the vhost for your new Rails 3 application. The culprit is a file config.ru which makes Passenger consider your application a Rack (non-Rails) application.

To fix this you can either use RackEnv in lieu of RailsEnv (it works fine) or delete the config.ru. Unless you have a good reason to do so, go with RackEnv.

When you want to format only line breaks, you probably do not want `simple_format`

Rendering text with only line-break handling can avoid simple_format's HTML-preserving side effects. A small helper or white-space: pre-wrap keeps output predictable.

Fix LoadError with Rails 3 applications on Passenger

After switching to Rails 3 you may get a LoadError with the following message when trying to use your application via passenger:
no such file to load -- dispatcher

Your Passenger version is most likely out of date.

Update the gem, then install the apache module again:
sudo gem install passenger
sudo passenger-install-apache2-module

Follow any instructions. Update your /etc/apache2/httpd.conf with the lines given at the end of the installation process to use the version you just installed.

Clean up application servers when deploying

Frequent deployments fill application servers with old releases, tmp files, and stale compiled assets. Capistrano can automate release and asset cleanup to prevent disk-space exhaustion.

Couldn't create database for ...

rake db:create fails when MySQL access or credentials are wrong, often because the configured user lacks permission to create the development database.

Compare library versions as "Gem::Version" instances, not as strings

String comparison can misorder gem and Ruby versions, letting newer releases slip past checks; Gem::Version gives reliable semantic version comparisons.

What’s Up With All These Changes in Rails?

Yesterday, there was a blog post entitled “What the Hell is Happening to Rails” that stayed at the number one spot on Hacker News for quite a while. The post and many (but not most) the comments on the post reflect deep-seated concern about the recent direction of Rails. Others have addressed the core question about change in the framework, but I’d like to address questions about specific changes that came up in the post and comments.

Run multiple local webricks at the same time using different ports

Run several local Rails servers at once by assigning each webrick instance a different port.

How to not die with ActionView::MissingTemplate when clients request weird formats

HTTP clients can request unsupported formats and trigger ActionView::MissingTemplate when only HTML templates exist; restricting routes or responding with 406 avoids the error.

How to load an SQL dump from a migration

Importing a MySQL dump inside an ActiveRecord migration can fail because the default connection accepts only one statement per query. A separate Mysql2::Client with multi-statement support avoids the syntax error.

Migrating from Elasticsearch to Opensearch: searchkick instructions (without downtime!)

Zero-downtime migration from Elasticsearch to OpenSearch for Searchkick apps, including staging validation, client switching, and environment-specific index settings.

wycats/artifice

Artifice allows you to replace the Net::HTTP subsystem of Ruby with an equivalent that routes all requests to a Rack application.

You can use Sinatra, raw Rack, or even Rails as your application, allowing you to build up an equivalent to the remote service you are mocking out using familiar and convenient tools to route requests and build up responses.

Writing a README for a project

A project README gives new developers a quick overview, key architecture, and setup notes. Keep it concise, focused on essentials, and separate detailed class documentation.

makandra/consul

Our new scope-based authorization gem for Ruby on Rails has been released. This might one day replace Aegis as our standard authorization solution.