# Generate action in slice, routes entries

**URL:** <https://discourse.hanakai.org/t/generate-action-in-slice-routes-entries/942>\
**Category:** questions\
**Created:** [April 8, 2024, 12:26pm UTC](https://discourse.hanakai.org/t/generate-action-in-slice-routes-entries/942 "2024-04-08T12:26:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![krzykamil](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/krzykamil/32/765_2.png) [@krzykamil](https://discourse.hanakai.org/u/krzykamil)\
**Post date:** [April 8, 2024, 12:26pm UTC](https://discourse.hanakai.org/t/generate-action-in-slice-routes-entries/942/1 "2024-04-08T12:26:49Z")

</div>

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

```auto
$ 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`

```ruby
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:

1. Created routes do not correspond to created actions. Entering those routes will result in Hanami::Routes::MissingActionError
2. Routes are not scoped in the slice
3. Routes for the slice are in general `config/routes.rb` instead of `slices/main/config/routes.rb`
4. (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.
