Action Mailer Basics and Previews Chapter "Task H1: Sending Confirmation Emails" from Agile Web Development with Rails (in our...
use Postgres' lower() function add an index on lower(email) Probably the best approach is to just convert emails (and usernames) to lowercase within Rails. Popular authentication libraries...
While debugging a SPF record I found spf-record.de to be very helpful. it lists all IPs that are covered by...
...to be performed around a deploy. Be it to notify operations about changed application behavior, be it to run a little oneline script after the deploy. Most database-related stuff...
Some users might use Adblock Plus or similar browser plugins to reduce the number of ads displayed. If you run...
...any cleanup yourself. Why? Understand this: before(:context) is run when the context/describe block begins, before(:context) is run outside of transactions, so data created here will bleed into other...
Understand what Memoization is and when it can be useful. Understand the @variable ||= computation pattern. Learn how to use...
For string columns, MySQL indexes the left side of a string. That means an index can speed a like query...
...in development + test, but keep action_on_unpermitted_parameters = false in production, your application behaves different between these environments. On the other hand it forces to fix these errors in...
...Parameters).to receive(:action_on_unpermitted_parameters).and_return(false) for tests, that should behave exactly like in production...
To allow HTTP 304 responses, Rails offers the fresh_when method for controllers. The most common way is to pass...
Rails offers a way to prepend (or append) view paths for the current request. This way, you can make the...
...record, :match_requests_on).except(:example_group) VCR.use_cassette(name, options) { example.call } end end Behaviour If a spec is not tagged with :vcr, VCR will complain about any attempted HTTP...
...request. This is the default behaviour. If you want to turn this off temporarily, e.g. to communicate with an actual API while writing a new spec, simply add the line...
} Enumerable#index_with (Rails 6+) To generate a hash where array elements become hash keys, and values are calculated from them, use index_with. users = User.all
The attached compiler() function below applies JavaScript behavior to matching HTML elements as they enter the DOM. This works like an Unpoly compiler for apps that don't use Unpoly...
This page lists many query methods and options in ActiveRecord which do not sanitize raw SQL arguments and are not...
...using a multiple assignment for a Regex are named groups. Especially when your Regex becomes more complicates it is easier to understand and to process. Note: In case a string...
...you will sign out your current user whenever you switch to another app. A better way is to use our own daho.im service. All daho.im subdomains resolve to your local...
Simplecov is a code coverage tool. This helps you to find out which parts of your application are not tested...
Rails is split into a large number of (sub-) frameworks. The most important and central of those are activesupport (extends...
Rails 7.1 added the normalizes method which can be used to normalize user input. It lets you define the fields...
...lockfile carefully when submitting a commit. Note that the approach in this card works best, if you use yarn outdated or npm outdated together with yarn upgrade some_package or...
...more information about this issue. In Rails3+ you can also disable this annoyingly clever behavior. Why this is bad This has some develish implications for your deployment, because scopes written...
...t notice this during development. Let's say you have a model Note which belongs to an Author and has a string column category: class Note < ActiveRecord::Base
...API (notable methods and properties) video = document.querySelector('video') video.play() video.pause() video.load() // Reset to the beginning and select the best available source video.currentSrc // The selected source video.currentTime // The current playback time...
...API design, I thought it might be nice to write down a set of best practices. And poke fun at a couple widely-used APIs. Much of this may be...