2010-07-04 11:08:00 -04:00
|
|
|
module Devise
|
|
|
|
module Generators
|
|
|
|
module OrmHelpers
|
|
|
|
def model_contents
|
|
|
|
<<-CONTENT
|
|
|
|
# Include default devise modules. Others available are:
|
2012-04-27 10:51:07 -04:00
|
|
|
# :token_authenticatable, :encryptable, :confirmable,
|
|
|
|
# :lockable, :timeoutable and :omniauthable
|
2010-07-04 11:08:00 -04:00
|
|
|
devise :database_authenticatable, :registerable,
|
|
|
|
:recoverable, :rememberable, :trackable, :validatable
|
|
|
|
|
|
|
|
CONTENT
|
|
|
|
end
|
|
|
|
|
|
|
|
def model_exists?
|
2010-12-09 17:03:48 -05:00
|
|
|
File.exists?(File.join(destination_root, model_path))
|
2010-07-04 11:08:00 -04:00
|
|
|
end
|
2011-08-29 18:53:32 -04:00
|
|
|
|
|
|
|
def migration_exists?(table_name)
|
|
|
|
Dir.glob("#{File.join(destination_root, migration_path)}/[0-9]*_*.rb").grep(/\d+_add_devise_to_#{table_name}.rb$/).first
|
|
|
|
end
|
|
|
|
|
|
|
|
def migration_path
|
|
|
|
@migration_path ||= File.join("db", "migrate")
|
|
|
|
end
|
2010-07-04 11:08:00 -04:00
|
|
|
|
|
|
|
def model_path
|
|
|
|
@model_path ||= File.join("app", "models", "#{file_path}.rb")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|