From 179cb2c88a2be958f942ddbe8100b5bd6bedc2c3 Mon Sep 17 00:00:00 2001 From: Sean Hill Date: Sun, 28 Aug 2011 16:02:58 -0500 Subject: [PATCH] Changed the order of the devise_generator methods to create the model after the migration to properly use model_exists?, and I added tests to prove the generator works. --- lib/generators/active_record/devise_generator.rb | 8 ++++---- test/generators/active_record_generator_test.rb | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/generators/active_record/devise_generator.rb b/lib/generators/active_record/devise_generator.rb index 448d723c..424f7f5e 100644 --- a/lib/generators/active_record/devise_generator.rb +++ b/lib/generators/active_record/devise_generator.rb @@ -9,10 +9,6 @@ module ActiveRecord include Devise::Generators::OrmHelpers source_root File.expand_path("../templates", __FILE__) - def generate_model - invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke - end - def copy_devise_migration unless model_exists? migration_template "migration.rb", "db/migrate/devise_create_#{table_name}" @@ -21,6 +17,10 @@ module ActiveRecord end end + def generate_model + invoke "active_record:model", [name], :migration => false unless model_exists? && behavior == :invoke + end + def inject_devise_content inject_into_class(model_path, class_name, model_contents + <