Replacing the joins method with the includes method to avoid the ActiveRecord::ReadOnly exception in the Regularcourse class