Sha256: 522bcd6f11eebe5616c84dc2062cf7e48a503497b094b42b0dd349611f5c35cc

Contents?: true

Size: 702 Bytes

Versions: 15

Compression:

Stored size: 702 Bytes

Contents

module MyAdmin
  
  module Generators

    class ModelGenerator < Rails::Generators::Base
  
      source_root File.expand_path('../templates', __FILE__)
      argument :model, :type => :string, :description => "Model Name"
      
      def generate_install
        directory = File.expand_path('../templates', __FILE__)
        template "controllers/controller.rb", "app/controllers/my_admin/#{controller_name.downcase}_controller.rb"
        
        File.open("#{Rails.root}/config/initializers/my_admin.rb", "a+"){|f| f << "\nMyAdmin::Application.add([#{model.camelize}])" }
        
      end
      
      def controller_name
        model.camelize.pluralize
      end
  
    end
    
  end
  
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
my_admin-0.1.4 lib/generators/my_admin/model/model_generator.rb
my_admin-0.1.3 lib/generators/my_admin/model/model_generator.rb
my_admin-0.1.2 lib/generators/my_admin/model/model_generator.rb
my_admin-0.1.1 lib/generators/my_admin/model/model_generator.rb
my_admin-0.0.12 lib/generators/my_admin/model/model_generator.rb
my_admin-0.0.11 lib/generators/my_admin/model/model_generator.rb
my_admin-0.0.10 lib/generators/my_admin/model/model_generator.rb
my_admin-0.0.9 lib/generators/my_admin/model/model_generator.rb
my_admin-0.0.8 lib/generators/my_admin/model/model_generator.rb
my_admin-0.0.7 lib/generators/my_admin/model/model_generator.rb
my_admin-0.0.6 lib/generators/my_admin/model/model_generator.rb
my_admin-0.0.5 lib/generators/my_admin/model/model_generator.rb
my_admin-0.0.4 lib/generators/my_admin/model/model_generator.rb
my_admin-0.0.3 lib/generators/my_admin/model/model_generator.rb
my_admin-0.0.2 lib/generators/my_admin/model/model_generator.rb