Class: RubyUIAdmin::Generators::EjectGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/ruby_ui_admin/eject/eject_generator.rb

Overview

Copies an engine controller / view component / UI primitive into the host app at the same path. The host's copy shadows the engine's (Zeitwerk loads the app's file first), so you can customize it freely.

rails g ruby_ui_admin:eject --view index
rails g ruby_ui_admin:eject --view layout
rails g ruby_ui_admin:eject --controller resources
rails g ruby_ui_admin:eject --ui button

Instance Method Summary collapse

Instance Method Details

#ejectObject



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/generators/ruby_ui_admin/eject/eject_generator.rb', line 25

def eject
  path = resolve_path
  return if path.nil?

  unless File.exist?(File.join(self.class.source_root, path))
    say "RubyUI Admin: nothing to eject at #{path}", :red
    return
  end

  copy_file path, path
  say "\nEjected #{path}. Edit it in your app to customize.", :green
end