Built-in matchers Get an overview of all the matchers that are built into RSpec. Play with some of...
Read the Rails Guide about Active Record migrations Understand why we never use models in migrations. Checkout the repository...
As you most likely know validates_uniqness_of :foreign_id does not allow nil values by default.
Use form models to handle this problem Or soften the validation to validates_presence_of :parent
Use base_class. This traverses up the hierarchy until it encounters either a class inheriting from ActiveRecord::Base or
Rubymonk training Read the following Rubymonk articles: Ruby Primer: Ascent (archived copy) Metaprogramming Ruby (archived copy) Metaprogramming Ruby: Ascent (archived...
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...
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...
Rails is our web framework. Goals Be able to write a simple Rails application. Understand how Rails talks to the...
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.
Capistrano 3 is a major rework of the framework and requires several adjustments to your deploy configuration files. The biggest...
Re-creating a complex ActiveRecord scenario quickly without setting up a full-blown Rails app can come in handy e.g...
Several Rails migration methods accept index: true as an option to create an index. In some cases (like #add_column...
You can freeze any Ruby object to prevent further modification. If you freeze an ActiveRecord and try to set an...
# Given the following models class Image < ActiveRecord::Base has_many :album_images has_many :albums, through: :album_images
You know that ActiveRecord caches associations so they are not loaded twice for the same object. You also know that...
Instead of this: Image.order('images.created_at DESC') You can write this: Image.order(created_at: :desc) Not only do you not...
Web applications can be used by multiple users at the same time. A typical application server like Passenger has multiple...
RSpec 3 has verifying doubles. This breed of mock objects check that any methods being stubbed are present on an...
When running migrations with rake db:migrate, there's the STEP and VERSION parameters that you can pass to nearly...