I think this is more of a question rather than bug report or anything else
Generating a new action for my slice, here is what I/O
$ hanami generate action sessions.create --slice=main
Updated config/routes.rb
Created slices/main/actions/sessions/
Created slices/main/actions/sessions/create.rb
Created slices/main/views/sessions/
Created slices/main/views/sessions/create.rb
Created slices/main/templates/sessions/
Created slices/main/templates/sessions/create.html.erb
Created spec/slices/main/actions/sessions/create_spec.rb
My resulting config/routes.rb
module Libus
class Routes < Hanami::Routes
post "/sessions", to: "sessions.create"
delete "/sessions/:id", to: "sessions.destroy"
slice :main, at: "/" #this was the only line before running the code
end
end
Some problems I see with this:
- Created routes do not correspond to created actions. Entering those routes will result in Hanami::Routes::MissingActionError
- Routes are not scoped in the slice
- Routes for the slice are in general
config/routes.rb
instead ofslices/main/config/routes.rb
- (very minor) For some reason indentation is incorrect
I sorted them from the most major to the most minor ones.
I think point 1 and 2 are bugs, we expect the generated code to immediately work and fulfill the parameters passed (so the routes should be scoped and working). Putting it in the correct file would be a nice addition, but requires for the hanami-cli to first look for routes.rb in the slice of given name and modify it instead of the regular one.
I could work on this (point 3) if it seems like a reasonable change, but the points 1 and 2 seem to simply be minor bugs, to be fixed.