mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Improve workflow with devise generator.
This commit is contained in:
parent
ae729aedc3
commit
e136573905
2 changed files with 13 additions and 2 deletions
|
@ -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 @@ class DeviseGenerator < Rails::Generators::NamedBase
|
|||
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 @@ CONTENT
|
|||
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue