Introduction
Introduction Statistics Contact Development Disclaimer Help
fixed the railtie and the migration generator - reportable - Fork of reportable…
Log
Files
Refs
README
---
commit ebfad6bda0a5db723b99ceaabe26b89a65d708a0
parent ddd609dc1bc709dfdfa85a0cf42ccda2134504c2
Author: Marco Otte-Witte <[email protected]>
Date: Sun, 18 Apr 2010 19:12:10 +0200
fixed the railtie and the migration generator
Diffstat:
M generators/reportable_migration/re… | 35 +++++++++++++++++++++++++++…
M generators/reportable_migration/te… | 2 +-
M lib/saulabs/reportable/railtie.rb | 8 +++++---
3 files changed, 37 insertions(+), 8 deletions(-)
---
diff --git a/generators/reportable_migration/reportable_migration_generator.rb …
@@ -1,9 +1,36 @@
-class ReportableMigrationGenerator < Rails::Generator::NamedBase
+if defined?(Rails) && Rails::VERSION::MAJOR >= 3
- def manifest
- record do |m|
- m.migration_template 'migration.erb', 'db/migrate'
+ require 'rails/generators'
+ require 'rails/generators/migration'
+
+ class ReportableMigrationGenerator < Rails::Generators::Base
+
+ include Rails::Generators::Migration
+
+ def create_migration
+ migration_template File.join(File.dirname(__FILE__), 'templates', 'migra…
+ end
+
+ def self.next_migration_number(dirname)
+ if ActiveRecord::Base.timestamped_migrations
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
+ else
+ "%.3d" % (current_migration_number(dirname) + 1)
+ end
+ end
+
+ end
+
+else
+
+ class ReportableMigrationGenerator < Rails::Generator::NamedBase
+
+ def manifest
+ record do |m|
+ m.migration_template 'migration.erb', 'db/migrate'
+ end
end
+
end
end
diff --git a/generators/reportable_migration/templates/migration.erb b/generato…
@@ -1,4 +1,4 @@
-class <%= class_name %> < ActiveRecord::Migration
+class CreateReportableCache < ActiveRecord::Migration
def self.up
create_table :reportable_cache, :force => true do |t|
diff --git a/lib/saulabs/reportable/railtie.rb b/lib/saulabs/reportable/railtie…
@@ -7,12 +7,14 @@ module Saulabs
class Railtie < Rails::Railtie
- railtie_name :reportable
-
- initializer 'saulabs.reportable.configure_rails_initialization' do
+ initializer 'saulabs.reportable.initialization' do
require File.join(File.dirname(__FILE__), '..', '..', '..', 'rails', '…
end
+ generators do
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'generator…
+ end
+
end
end
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.