What Rails version Within before_* Within after_* Cancel later callbacks Rails 1-4 return false return false Cancel later callbacks...

This error occurs when you already have a database.yml which defines the database for the cucumber environment instead of test...

Say you have a User with a Carrierwave attribute #avatar: class User < ActiveRecord::Base mount_uploader :avatar, AvatarUploader end

stackoverflow.com

When you want to find out the data type of an attribute, you can just use ActiveRecord's columns_hash...

Whenever you create a table from a database migration, remember to add updated_at and created_at timestamps to that...

Rails has always included a scaffold script that generates a default controller implementation for you. Unfortunately that generated controller is...

When writing Rails migrations to convert a string column to an integer you'd usually say: change_column :table_name...

I recently experienced the error ActiveRecord::StatementInvalid: Mysql2::Error: closed MySQL connection. Apparently this happens when there is a timeout...

dusen 0.4.8 and edge_rider 0.2.3 no longer depend on Rails (they still depend on ActiveRecord). That means you can...

apidock.com

When you're writing migrations that do more than changing tables (like, modify many records) you may want some output...

We tend to use database transactions as a magic bullet to get rid of all our concurrency problems. When things...

blog.bigbinary.com

Remember why preloading associations "randomly" uses joined tables or multiple queries? If you don't like the cleverness of this...

Active Record's select method allows you to make use of the power of MySQL select statements. On the one...

Merge requests are often rejected for similar reasons. To avoid this, before you send a merge request, please confirm that...

You have multiple options: Just don't have a type column. All STI magic will be disabled automatically.

ActiveRecord translations live in locale.activerecord. ActiveModel translations live in locale.activemodel. To use the same translations for both, use YAML references...

Authentication is hard: there are many edge cases, and most users (including yourself) usually only go the "happy path" once...

We have often felt the pain where our models need to serve too many masters. E.g. we are adding a...

In the following example the method update_offices_people_count won't be called when office_id changes, because it...

Rails gives you migrations to change your database schema with simple commands like add_column or update. Unfortunately these commands...

Caution when using .where to exclude records from a scope like this: # Fragile - avoid User.where("id NOT IN (?)", excluded_ids...

apidock.com

All columns of a model's database table are automagically available through accessors on the Active Record object.

Rails has generic error messages you can define in your locale .yml files. You may override those application-wide error...

Sometimes you might want to limit the number of associated records in a has_many association, but cannot add a...