rubyhanami

Delete record from console in Hanami


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.


Solution

  • You can do

    $ hanami c
    UserRepository.new.users.where(name: "Test Record").delete