Permalink
Browse files

Improve workflow with devise generator.

  • Loading branch information...
1 parent ae729ae commit e136573905f1cef6c02f700f9ec0772da349f1c8 @josevalim josevalim committed Mar 26, 2010
Showing with 13 additions and 2 deletions.
  1. +1 −0 CHANGELOG.rdoc
  2. +12 −2 lib/generators/devise/devise_generator.rb
View
@@ -12,6 +12,7 @@
* Move trackable logic to the model.
* E-mails now use any template available in the filesystem. Easy to create multipart e-mails.
* E-mails asks headers_for in the model to set the proper headers.
+ * Allow to specify haml in devise_views.
* bug fix
* Do not use lock! on lockable since it's part of ActiveRecord API.
@@ -18,13 +18,19 @@ def self.next_migration_number(path)
Time.now.utc.strftime("%Y%m%d%H%M%S")
end
+ class_option :orm
class_option :migration, :type => :boolean, :default => orm_has_migration?
def invoke_orm_model
- if File.exists?(File.join(destination_root, model_path))
+ if model_exists?
say "* Model already exists. Adding Devise behavior."
else
- invoke "model", [name], :migration => false
+ invoke "model", [name], :migration => false, :orm => options[:orm]
+
+ unless model_exists?
+ abort "Tried to invoke the model generator for '#{options[:orm]}' but could not find it.\n" <<
+ "Please create your model by hand before calling `rails g devise #{name}`."
+ end
end
end
@@ -51,6 +57,10 @@ def add_devise_routes
protected
+ def model_exists?
+ File.exists?(File.join(destination_root, model_path))
+ end
+
def model_path
@model_path ||= File.join("app", "models", "#{file_path}.rb")
end

0 comments on commit e136573

Please sign in to comment.