Skip to content

Cannot use most CLI commands in a Rails app with Hanami slices #438

Description

@sandbergja

Describe the bug

We are working to incrementally migrate a Rails application to Hanami, gradually replacing an area of the Rails code with its own dedicated slice as we go (taking this post as inspiration and a template). As such, we have Hanami stuff in slices/**/* and config/initializers/load_hanami.rb, but nothing in config/app.rb.

To Reproduce

rails new ibis
cd ibis
bundle add hanami
cat << END_INITIALIZER > config/initializers/load_hanami.rb
require 'hanami'
module IbisHanami
  class App < Hanami::App
    prepare_container { |container| container.autoloader.ignore('app') }
  end
end
Hanami.boot
END_INITIALIZER
mkdir -p slices/osprey
cat << END_SLICE > slices/osprey/my_class.rb
module Osprey
  class MyClass
    def call = 'Hello from slice!'
  end
end
END_SLICE
hanami g slice pigeon # does not generate a new slice, instead gives the usage docs for creating a new Hanami app

Expected behavior

It would be nice if there were a way to use the convenient CLI commands in applications that use hanami, but define their Hanami::App somewhere other than config/app.rb

My environment

  • Ruby version: 3.4
  • OS: I have seen this on both Mac OS and Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions