Sha256: cf1d95e00c89f2e48ec416e724536bcd81a5c349e37ad01ed796ebe85d98e928

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'rails/generators/active_record'

module Radmin
  module Generators
    class InstallGenerator < Rails::Generators::Base
      include Rails::Generators::Migration
      source_root File.expand_path("../templates", __FILE__)

      def copy_migrations
        mig_dir = 'db/migrate'
        Dir[File.join(self.class.source_root,'migrations','*.rb')].sort!.each do |m|
          mig_name = File.basename(m).sub(/\.rb$/, '')
          new_name = mig_name.gsub(/^[0-9].*?_/, '')
          unless self.class.migration_exists?(mig_dir, new_name)
            mig_number = ActiveRecord::Generators::Base.next_migration_number(mig_dir)
            destination = File.join(mig_dir, "#{mig_number}_#{new_name}.rb")
            template("migrations/#{mig_name}.rb", destination)
          end
        end
      end
      
      def copy_assets
        directory 'assets', 'public', :recursive => true
      end
      
      def copy_authorization_file
        template "authorization_rules.rb", "config/authorization_rules.rb"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
radmin-0.2.0 lib/generators/radmin/install_generator.rb