cli
cli copied to clipboard
Action generator appends routes even if exists
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 ?
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)
)
Yes, I believe so, duplicates have no sense.
Yes, I would love help with a fix for this!