Permalink
Browse files

fixed the activerecord not found by defining generator class only if …

…it comes from rails model generator
  • Loading branch information...
1 parent bd749cb commit 67a4078c6f8c6d8221093dfdee8849ef1081d599 @mkristian committed Oct 14, 2011
Showing with 7 additions and 5 deletions.
  1. +7 −5 lib/generators/rails/active_record/active_record_generator.rb
@@ -1,4 +1,5 @@
-if defined?(ActiveRecord) && !defined?(Rake) #when run from rake ignore this as well since otherwise active_record is not found
+# just definde the class if it comes from the rails model generator
+if defined?(Rails::Generators::ModelGenerator) && defined?(ActiveRecord)
require 'rails/generators/active_record/model/model_generator'
module ActiveRecord
@@ -10,10 +11,11 @@ class ModelGenerator < Base
check_class_collision
- class_option :migration, :type => :boolean
- class_option :timestamps, :type => :boolean
- class_option :modified_by, :type => :string
- class_option :parent, :type => :string, :desc => "The parent class for the generated model"
+ class_option :migration, :type => :boolean
+ class_option :timestamps, :type => :boolean
+ class_option :modified_by, :type => :boolean, :default => false
+ class_option :singleton, :type => :boolean, :default => false
+ class_option :parent, :type => :string, :desc => "The parent class for the generated model"
def create_migration_file
return unless options[:migration] && options[:parent].nil?

0 comments on commit 67a4078

Please sign in to comment.