By default, Rails' validates_uniqueness_of does not consider "username" and "USERNAME" to be a collision. If you use MySQL...

makandra dev

When you call a method on an object, Ruby looks for the implementation of that method. It looks in the...

Tests are about 100% control over UI interaction and your test scenario. Randomness makes writing tests hard. You will also...

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

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

When HTTP clients make an request they can define which response formats they can process. They do it by adding...

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

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

JavaScript has no built-in functions to compare two objects or arrays for equality of their contained values.

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

TLDR: Ruby class variables (@@foo) are dangerous in many ways. You should avoid them at all cost. See bottom of...

Ruby has two different ways to match the start and the end of a text: ^ (Start of line) and $ (End...

validates_uniqueness_of is not sufficient to ensure the uniqueness of a value. The reason for this is that in...

Calling bundle update GEMNAME will update a lot more gems than you think. E.g. when you do this...

Calling bundle update (without arguments) updates all your gems at once. Given that many gems don't care about stable...

makandra dev

Basic error pages To add a few basic styles to the default error pages in Rails, just edit the default...