Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action generator appends routes even if exists #146

Open
Lucas-Barret opened this issue May 12, 2024 · 3 comments
Open

Action generator appends routes even if exists #146

Lucas-Barret opened this issue May 12, 2024 · 3 comments

Comments

@Lucas-Barret
Copy link

Lucas-Barret commented May 12, 2024

When you execute bundle exec hanami generate action books.index several times.
You end up with the same routes in routes.rb
Example :

$ bundle exec hanami generate action books.index
$ bundle exec hanami generate action books.index

## config/routes.rb

module Bookshelf
  class Routes < Hanami::Routes
    get "/books", to: "books.index"
    get "/books", to: "books.index"
  end
end

We should have the root only one time what do you think ?

@Lucas-Barret
Copy link
Author

After some investigation it seems it comes from this piece of code :
Should we check if the routes is already in the file ?

            fs.inject_line_at_class_bottom(
              fs.join("config", "routes.rb"),
              "class Routes",
              route(controller, action, url, http)
            )

@swilgosz
Copy link
Member

Yes, I believe so, duplicates have no sense.

@timriley
Copy link
Member

Yes, I would love help with a fix for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants