In tests, it is sometimes useful to create records with specific ids. On PostgreSQL this can cause problems: Usually, PostgreSQL...
Read (or re-read) the following chapters from our book Growing Rails Applications in Practice (it’s in our...
A common task in web applications is to add client-side JavaScript behavior to existing HTML elements.
The migration DSL now supports adding and removing foreign keys. They are dumped to schema.rb as well. At this time...
Learn to treat files as an ActiveRecord attribute type, like :string or :integer Research Look at the README for...
In this card we will learn to write code that scales with a large number of database records. We will...
Understand why we use pagination Exercises Create 7500 movies in MovieDB (hint: Doing it in a single transaction is...
In most of our applications, users have their first and last name stored in separate columns. However, specifying them separately...
Understand why we test: Low defect rate without a QA department. Customer acceptance testing can concentrate on new features...
Rails is our web framework. Goals Be able to write a simple Rails application. Understand how Rails talks to the...
Git is our version control system. Goals Understand why we use git. Learn how to work with your local repository...
When using ORDER BY "column" in PostgreSQL, NULL values will come last. When using ORDER BY "column" DESC, NULLs will...
In my RubyMine I have recorded two macros for debugging and linked them to some keyboard shortcuts. Since I believe...
When working with ActiveType you will often find it useful to cast an ActiveRecord instance to its extended ActiveType::Record...
Note: ActiveRecord::Base#becomes has a lot of quirks and inconsistent behavior. You probably want to use ActiveType.cast instead.
There is no such thing as a "default order" of rows in database tables. For instance, when you paginate a...
ActiveModel supplies an errors object that behaves similar to a Hash. It can be used to add errors to a...
FactoryBot.define do factory :parent do transient do child_name nil child_allowed_to_drive false end child do association(:child...
When using Savon to connect a SOAP API, you may want to use Savon::SpecHelper to mock requests in your...
Re-creating a complex ActiveRecord scenario quickly without setting up a full-blown Rails app can come in handy e.g...
When you want to UPDATE a table with information from an associated table, you can JOIN the associated table into...
Several Rails migration methods accept index: true as an option to create an index. In some cases (like #add_column...
# Given the following models class Image < ActiveRecord::Base has_many :album_images has_many :albums, through: :album_images
When ending a Selenium test Capybara resets the browser state by closing the tab, clearing cookies, localStorage, etc.