Class: Fetty::Generators::ScaffoldGenerator

Inherits:
Base
  • Object
show all
Includes:
Scaffold, Rails::Generators::Migration
Defined in:
lib/generators/fetty/scaffold/scaffold_generator.rb

Instance Method Summary collapse

Methods included from Scaffold

#action?, #actions?, #class_name, #controller_name, #generate_action_links, #generate_route_link, #generate_routes, #has_namespace?, #has_type?, #helper_name, included, #instance_name, #instances_name, #migration_name, #model_name, #plural_name, #record_or_name_or_array, #resource_name, #resources_name, #setting_controller_attributes, #setting_model_attributes, #simple_name, #singular_name, #special_select, #table_name

Methods inherited from Base

banner, source_root

Instance Method Details

#generate_scaffoldObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/generators/fetty/scaffold/scaffold_generator.rb', line 24

def generate_scaffold
  print_usage unless scaffold_name.underscore =~ /^[a-z][a-z0-9_\/]+$/ && !attributes.empty?
  print_usage unless attributes.drop_while { |arg| arg.include?(':') }.count == 0
  
  @orm = using_mongoid? ? 'mongoid' : 'active_record'
  
  setting_model_attributes
  if options[:model]
     generate_model
     if options.migration? && !using_mongoid?
        generate_migration
      end
  end
  
  if options.controller?
     setting_controller_attributes
     generate_controller
     generate_helper
     generate_views
     generate_routes
  end
  
  if options.test?
    generate_test_unit if using_test_unit?
    generate_specs if using_rspec?
  end
  
rescue Exception => e
   print_notes(e.message,"error",:red)
end