belongs_to
association is required by default in Rails 5. If I have a User/Profile relationship, I cannot create a Profile that doesn't belong to a User (by default). I can make the association not required by declaring belongs_to :user, required: false
. I have mixed feelings about this. Having the parent record be required for a child makes logical sense, and is almost always the behavior I want, but it makes testing harder. For example, if I want to test some model methods on my Profile model, I have to create an associated User model too, which makes the test build-up harder to configure, and slows down my test suite. I'm going to dig more into this to find the right balance.ApplicationRecord
instead of ActiveRecord::Base
. This seems to simply add a thin layer in which functionality can be mixed-in for only the parent application and kept out of related engines, etc.spec_helper.rb
file which is itself required by rails_helper.rb
. I simply moved the SimpleCov statements to the top of rails_helper.rb
and the stats appear much more accurately.Written by Alex Brinkman who lives and works in Denver, but plays in the mountains.