If your project manager wants to do gatekeeping on a project, as a developer you need to follow the following...
When your model is using a callback like before_save or before_validation to calculate an aggregated value from its...
When selecting records in a date range, take care not to do it like this: start_date = Date.parse('2007-05...
Basically, you now need to know if your project uses a "real" time zone or :local, and if config.active_record.time_zone...
By default, Rails views escape HTML in any strings you insert. If you want to insert HTML verbatim, you need...
While it might seem trivial to implement an invoice that sums up items and shows net, gross and vat totals...
Detecting if a Javascript is running under Selenium WebDriver is super-painful. It's much easier to detect the current...
When you need to create a locale for a language variant (like Austrian for German), you probably don't want...
When you generate a URL in a mailer view, ActionMailer will raise an error unless you previously configured it which...
Here are some popular mistakes when using nested forms: You are using fields_for instead of form.fields_for.
(Rails has a method ActiveRecord::Relation#merge that can merge ActiveRecord scopes. However, its behavior has never been clear, and...
Remember that your controller actions share the same method space with private methods defined in ActionController::Base. If your controller...
We often have a separate production branch that lags a bit behind the more cutting edge main branch. Sometimes you...
Occasionally you need to do something directly on the server -- like having all records recalculate something that cannot be done...
When storing floating-point numbers such as prices or totals in an SQL database, always use a DECIMAL column. Never...
Within an event handler, there are multiple methods to cancel event propagation, each with different semantics. event.preventDefault() Only prevents the...
When you need to insert many records into the same table, performance may become an issue. What you can do...
So you are comparing two Time objects in an RSpec example, and they are not equal, although they look equal...
There are two ways to define a class method from a Modularity trait. Note that the usual caveats regarding class...
A check if two date or time ranges A and B overlap needs to cover a lot of cases:
When defining a trait using the Modularity gem, you must take extra steps to define constants to avoid caveats (like...
You cannot use Array#join on an array of strings where some strings are html_safe and others are not...
When you eagerly load an association list using the .include option, and at the same time have a .where on...
When using virtual attributes, the attached trait can be useful to automatically copy errors from one attribute to another.