2

In Rails you can do:

rails c
record = Record.where(name: 'Test Record').first
record.destroy

How can you do the same in Hanami? I've been reading through the docs but I'm struggling to see how to do console commands like Rails to interact with the database objects.

Cameron
  • 27,963
  • 100
  • 281
  • 483

2 Answers2

4

You can do

$ hanami c
UserRepository.new.users.where(name: "Test Record").delete
Luca Guidi
  • 1,201
  • 10
  • 10
1

When a class inherits from Hanami::Repository

delete(id) – Delete the record corresponding to the given id

in Hanami use delete instead of destroy