Class: TurboCrud::Generators::ScaffoldGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- TurboCrud::Generators::ScaffoldGenerator
- Includes:
- InstallSupport
- Defined in:
- lib/generators/turbo_crud/scaffold_generator.rb
Constant Summary collapse
- VALID_CONTAINERS =
%w[modal drawer both].freeze
Instance Method Summary collapse
- #create_controller ⇒ Object
- #create_views ⇒ Object
- #generate_model_and_routes_if_full ⇒ Object
- #install_if_requested ⇒ Object
- #validate_options! ⇒ Object
Instance Method Details
#create_controller ⇒ Object
76 77 78 |
# File 'lib/generators/turbo_crud/scaffold_generator.rb', line 76 def create_controller template "controller.rb.tt", "app/controllers/#{plural_name}_controller.rb" end |
#create_views ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/generators/turbo_crud/scaffold_generator.rb', line 80 def create_views return if [:wrap_existing] @generated_fields = build_fields_markup @generated_row_fields = build_row_fields_markup template "views/index.html.erb.tt", "app/views/#{plural_name}/index.html.erb" template "views/_row.html.erb.tt", "app/views/#{plural_name}/_row.html.erb" template "views/_form.html.erb.tt", "app/views/#{plural_name}/_form.html.erb" case normalized_container when "modal" template "views/new.html.erb.tt", "app/views/#{plural_name}/new.html.erb" template "views/edit.html.erb.tt", "app/views/#{plural_name}/edit.html.erb" when "drawer" template "views/new.drawer.html.erb.tt", "app/views/#{plural_name}/new.html.erb" template "views/edit.drawer.html.erb.tt", "app/views/#{plural_name}/edit.html.erb" when "both" template "views/new.html.erb.tt", "app/views/#{plural_name}/new.html.erb" template "views/edit.html.erb.tt", "app/views/#{plural_name}/edit.html.erb" template "views/new.drawer.html.erb.tt", "app/views/#{plural_name}/new.drawer.html.erb" template "views/edit.drawer.html.erb.tt", "app/views/#{plural_name}/edit.drawer.html.erb" end end |
#generate_model_and_routes_if_full ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/generators/turbo_crud/scaffold_generator.rb', line 68 def generate_model_and_routes_if_full return unless [:full] generate_model unless [:skip_model] inject_routes unless [:skip_routes] run_migrations_if_full end |
#install_if_requested ⇒ Object
105 106 107 108 109 110 |
# File 'lib/generators/turbo_crud/scaffold_generator.rb', line 105 def install_if_requested return unless should_install? install_layout_frames install_sprockets_css end |
#validate_options! ⇒ Object
61 62 63 64 65 66 |
# File 'lib/generators/turbo_crud/scaffold_generator.rb', line 61 def return if VALID_CONTAINERS.include?(normalized_container) raise Thor::Error, "Invalid --container=#{options[:container].inspect}. Expected one of: #{VALID_CONTAINERS.join(', ')}." end |