Hi,
When I try to destroy a generated content resource, rails destroy content Page crashes with an Errno::ENOENT because it attempts to operate on app/controllers/content/pages_controller.rb after that file has already been removed.
Steps to reproduce
rails generate content Page
Generates:
create app/models/content/page.rb
create app/controllers/content/pages_controller.rb
create app/views/content/pages
create app/views/content/pages/index.html.erb
create app/views/content/pages/show.html.erb
route resources :pages, module: :content, only: %w[index show]
insert app/controllers/content/pages_controller.rb
create app/content/pages/root.erb
route root to: "content/pages#root"
rails destroy content Page
Output:
remove app/models/content/page.rb
remove app/controllers/content/pages_controller.rb
remove app/views/content/pages
remove app/views/content/pages/index.html.erb
remove app/views/content/pages/show.html.erb
route resources :pages, module: :content, only: %w[index show]
subtract app/controllers/content/pages_controller.rb
... then crash:
Errno::ENOENT: No such file or directory @ rb_sysopen -
app/controllers/content/pages_controller.rb
Actual behavior
rails destroy content Page raises:
Errno::ENOENT: No such file or directory @ rb_sysopen -
app/controllers/content/pages_controller.rb
The Thor inject_into_file / inject_into_class revoke step runs after the file has already been removed.
Expected behavior
rails destroy content Page should:
- remove the generated model, controller, and views,
- remove the injected routes,
- remove
app/content/pages/root.erb,
- and clean up any injected code in
pages_controller.rb without crashing, skipping the revoke step if the file has already been deleted.
Environment
- Ruby: 4.0.2
- Rails: 8.1.2
- Perron: 0.18.0
Hi,
When I try to destroy a generated content resource,
rails destroy content Pagecrashes with anErrno::ENOENTbecause it attempts to operate onapp/controllers/content/pages_controller.rbafter that file has already been removed.Steps to reproduce
rails generate content PageGenerates:
rails destroy content PageOutput:
Actual behavior
rails destroy content Pageraises:Errno::ENOENT: No such file or directory @ rb_sysopen -
app/controllers/content/pages_controller.rb
The Thor
inject_into_file/inject_into_classrevoke step runs after the file has already been removed.Expected behavior
rails destroy content Pageshould:app/content/pages/root.erb,pages_controller.rbwithout crashing, skipping the revoke step if the file has already been deleted.Environment