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

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

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

When two classes implement the same behavior (methods, callbacks, etc.), you should extract that behavior into a trait or module...

Custom matchers are a useful RSpec feature which you can use to DRY up repetitive expectations in your specs. Unfortunately...

makandracards.com

So you're hunting down a regression (or just a bug) and want to use git bisect to find out...

blog.bigbinary.com

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

1. Saving files to a directory that is not shared between deploys or servers If you save your uploads to...

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

Sometimes you want git to ignore certain files that appear on your machine. You can do this in 3 ways...

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...

Be careful with the Active Record where method. When you accidentally pass an empty array to the where method using...

makandra dev
aaronlasseigne.com

All Rubyists should be familiar with the common definitions for include and extend. You include a module to add instance...

apidock.com

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

thejh.net

What you copy may not be what you see in the browser. Here is an online tool to determine the...

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

Do not pass times to date attributes. Always convert times to dates when your application uses time zones. Background

robots.thoughtbot.com

Guide how to make fixes in other people's GitHub repositories. It's basically "Open Source Development 101".

web.archive.org

TL;DR: You should generally use #size to count associated records. size Counts already loaded elements If the association is...

mysqlperformanceblog.com

When MySQL refuses to use your index, there's a number of things that you may be doing wrong. One...

Don't Google this, you will lose all will to live. Instead use Object#isEqual() from Lodash or Underscore.js:

makandra dev
rails-sqli.org

This page lists many query methods and options in ActiveRecord which do not sanitize raw SQL arguments and are not...

The Edge Rider gem gives your relations a method #traverse_association which returns a new relation by "pivoting" around a...