Skip to content

Commit

Permalink
Document that .find() still works with PK (excid3#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuchsfelipel authored Jan 23, 2023
1 parent 83534a0 commit 9995eec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ User.prefix_id

##### Query by Prefixed ID

To query using the prefixed ID, you can use either `find` or `find_by_prefix_id`:
To query using the prefixed ID, you can use either `find`, `find_by_prefix_id`, or `find_by_prefix_id!`:

```ruby
User.find("user_5vJjbzXq9KrLEMm32iAnOP0xGDYk6dpe")
User.find_by_prefix_id("user_5vJjbzXq9KrLEMm32iAnOP0xGDYk6dpe")
```

⚠️ Note that `find` still finds records by the primary key. Eg. `localhost/users/1` still works.
If you're targeting security issues by masking the ID, make sure to use `find_by_prefix_id` and [add a salt](#salt).

We also override `to_param` by default so it'll be used in URLs automatically.

To disable find and to_param overrides, simply pass in the options:
Expand Down

0 comments on commit 9995eec

Please sign in to comment.