Class: AdminInterface::Generators::Scaffold
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- AdminInterface::Generators::Scaffold
- Includes:
- Rails::Generators::ResourceHelpers
- Defined in:
- lib/generators/admin_interface/scaffold_generator.rb
Constant Summary collapse
- CONTROLLER_PATH =
'app/controllers/admin'
- VIEW_PATH =
MODEL_PATH = ‘app/models/admin’
'app/views/admin'
Instance Method Summary collapse
-
#check_class_collisions ⇒ Object
TODO.
-
#controller_plural_name ⇒ Object
(also: #controller_table_name)
default_options :skip_timestamps => false, :skip_migration => false, :force_plural => false.
- #copy_controller_files ⇒ Object
- #create_admin_scaffold ⇒ Object
Instance Method Details
#check_class_collisions ⇒ Object
TODO
30 31 32 33 |
# File 'lib/generators/admin_interface/scaffold_generator.rb', line 30 def check_class_collisions # TODO # Check for class naming collisions. # class_collisions class_path, "Admin::#{class_name}Controller" end |
#controller_plural_name ⇒ Object Also known as: controller_table_name
default_options :skip_timestamps => false, :skip_migration => false, :force_plural => false
23 24 25 |
# File 'lib/generators/admin_interface/scaffold_generator.rb', line 23 def controller_plural_name @name.pluralize.downcase end |
#copy_controller_files ⇒ Object
35 36 37 |
# File 'lib/generators/admin_interface/scaffold_generator.rb', line 35 def copy_controller_files template 'scaffold/controller.rb', File.join(CONTROLLER_PATH, class_path, "#{controller_file_name}_controller.rb") end |
#create_admin_scaffold ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/generators/admin_interface/scaffold_generator.rb', line 39 def create_admin_scaffold @name = file_name if @name == @name.pluralize && ![:force_plural] puts "Plural version of the model detected, using singularized version. Override with --force-plural." @name = @name.singularize end for action in scaffold_views template( "scaffold/view_#{action}.html.erb", File.join(VIEW_PATH, controller_class_path, controller_file_name, "#{action}.html.erb") ) end template 'scaffold/view_form_partial.html.erb', File.join(VIEW_PATH, controller_class_path, controller_file_name, "_form.html.erb") readme 'scaffold/INSTALL' end |