lib/generators/cable/menu/menu_generator.rb in cable-0.9.1 vs lib/generators/cable/menu/menu_generator.rb in cable-0.9.3

- old
+ new

@@ -16,48 +16,46 @@ class_option :views, :type => :boolean, :default => true class_option :routes, :type => :boolean, :default => true def create_migration_file if options.migration? - migration_template 'migration.rb', "db/migrate/create_#{model_name.pluralize}.rb" + migration_template 'migration.rb', "db/migrate/create_#{model_name.pluralize}.rb" if yes?("Would you like to generate a migration?") end end def create_model_file if options.model? - template 'model.rb' , "app/models/#{model_name}.rb" + template 'model.rb' , "app/models/#{model_name}.rb" if yes?("Would you like to generate a model?") end end def create_controller_file if options.controller? - template 'controller.rb', "app/controllers/admin/#{model_name.pluralize}_controller.rb" + template 'controller.rb', "app/controllers/admin/#{model_name.pluralize}_controller.rb" if yes?("Would you like to generate a controller?") end end def create_views if options.views? - Dir.glob(File.expand_path("../templates", __FILE__) + '/erb/menus/*.erb') do |rb_file| - template rb_file, "app/views/admin/#{plural_table_name}/#{File.basename(rb_file)}" + if yes?( "Would you like Cable to generate menu views?") + Dir.glob(File.expand_path("../templates", __FILE__) + '/erb/menus/*.erb') do |rb_file| + template rb_file, "app/views/admin/#{plural_table_name}/#{File.basename(rb_file)}" + end + copy_file 'erb/partials/_menu_fields.html.erb', 'app/views/admin/partials/_menu_fields.html.erb' end - copy_file 'erb/partials/_menu_fields.html.erb', 'app/views/admin/partials/_menu_fields.html.erb' end end def create_routes route_string = <<EOF cable_to :#{plural_table_name} do |menu| collection do - get :rebuild - get :table post :sort - post :move - post :remove_resource end end EOF - route( route_string ) + route( route_string ) if yes?("Would you like to generate routes?") end # Implement the required interface for Rails::Generators::Migration. # taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb