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.
Web applications can be used by multiple users at the same time. A typical application server like Passenger has multiple...
See this Railscast. Basically you can simply write views like index.xlsx.erb: ID Name Release Date Price <% @products.each do |product| %> <%= product.id...
Write a // and indent every subsequent line by two spaces. This is great for documenting BEM blocks! // An action button...
SELECT table_name, table_rows FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'your_database' order by table_rows;
Obviously, you only can do this for your own sites. You need to authenticate a domain you want to remove...
The linked article explains how to get a database-wide lock without creating table rows: This article explains how I...
The CSS property z-index is not as global as you might think. Actually, it is scoped to a so...
tldr; Use git diff -M or git diff --find-renames when you've moved a few files around. Usage
If you want to load an SQL dump from an ActiveRecord migration, you might find this to be harder than...
Using uncountable resources is not recommended as it breaks Rails' magic, e.g. when using form_for. You'll always be...
In the tradition of our PostgreSQL cheat sheet for MySQL lamers, here is a cheat sheet for Jasmine when you...
You can do so much more than console.log(...)! See the attached link for a great breakdown of what the developer...
Rails guide that covers PostgreSQL-specific column types and usages for Active Record. You should especially keep in mind the...