---
title: 'This week in #dev (Jul 14, 2023)'
teaser: 'Lots of Active Record goodies, VS Code features, and a Heroku CLI extension.

  '
tags: this week in dev,rails,vs code,security,heroku
author: thoughtbot
published_on: 2023-07-25
---

Welcome to another edition of [This Week in #dev], a series of posts where we
bring some of the most interesting Slack conversations to the public.

## `find`ing multiple records by id

[Elisa] found out that you can pass an array of record ids to Active
Record's [`find`] method. It will return an array of model objects with
those ids.

[Neil] added that if any of those ids don't exist, Active Record will raise an
`ActiveRecord::RecordNotFound`, just like it does with one single id.

[`find`]: https://api.rubyonrails.org/classes/ActiveRecord/FinderMethods.html#method-i-find

## VS Code: You might not need that extension

[Matheus Richard] talked about how Visual Studio Code sometimes adds new features
that may make some extensions unnecessary. He shared [a blog post that discusses
some of those features].

<aside class="info">
  <p>There's also a part two linked at the bottom of the article. Don't miss it!</p>
</aside>

[a blog post that discusses some of those features]: https://www.roboleary.net/vscode/2020/08/05/dont-need-extensions.html

## Secure Tokens with Active Record

[Summer ☀️] provided instructions on how to generate a random, unique key/token in
an Active Record model using the [`has_secure_token`] method.

```rb
# Schema: User(token:string, auth_token:string)
class User < ActiveRecord::Base
  has_secure_token
  has_secure_token :auth_token, length: 36
end

user = User.new
user.save
user.token # => "pX27zsMN2ViQKta1bGfLmVJE"
user.auth_token # => "tU9bLuZseefXQ4yQxQo8wjtBvsAfPc78os6R"
user.regenerate_token # => true
user.regenerate_auth_token # => true
```

[`has_secure_token`]: https://api.rubyonrails.org/classes/ActiveRecord/SecureToken/ClassMethods.html#method-i-has_secure_token

## Easily Manage Multiple Heroku Accounts with CLI Extension

[Fer] shared [a Heroku CLI extension] that allows users to have multiple
accounts set up and switch between them with a single command, making it easier
to use multiple Heroku accounts in the terminal.

[a Heroku CLI extension]: https://github.com/heroku/heroku-accounts

## Thanks

This edition was brought to you by: [Elisa Verna][elisa], [Fer Perales][fer], [Matheus Richard], [Neil Carvalho][neil],
and [Summer ☀️]. Thanks to all contributors! 🎉

[elisa]: https://github.com/elisuh
[matheus richard]: https://thoughtbot.com/blog/authors/matheus-richard
[fer]: https://github.com/ferperales
[neil]: https://thoughtbot.com/blog/authors/neil-carvalho
[Summer ☀️]: https://thoughtbot.com/blog/authors/summer
[This Week in #dev]: https://thoughtbot.com/blog/tags/this-week-in-dev
