mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Moved devise_install to rails 3 generators.
This commit is contained in:
parent
38bfe3f990
commit
443a2d8343
7 changed files with 28 additions and 23 deletions
|
@ -1,3 +0,0 @@
|
|||
To copy a Devise initializer to your Rails App, with some configuration values, just do:
|
||||
|
||||
script/generate devise_install
|
|
@ -1,15 +0,0 @@
|
|||
class DeviseInstallGenerator < Rails::Generator::Base
|
||||
|
||||
def manifest
|
||||
record do |m|
|
||||
m.directory "config/initializers"
|
||||
m.template "devise.rb", "config/initializers/devise.rb"
|
||||
|
||||
m.directory "config/locales"
|
||||
m.file "../../../lib/devise/locales/en.yml", "config/locales/devise.en.yml"
|
||||
|
||||
m.readme "README"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -1,5 +0,0 @@
|
|||
To create a devise resource user:
|
||||
|
||||
script/generate devise User
|
||||
|
||||
This will generate a model named User (if one does not exist), add devise configuration, a route map for devise called :users and a migration file for table :users with default devise modules.
|
|
@ -3,6 +3,9 @@ require 'rails/generators/migration'
|
|||
class DeviseGenerator < Rails::Generators::NamedBase
|
||||
include Rails::Generators::Migration
|
||||
|
||||
desc "Generates a model with the given NAME (if one does not exist) with devise " <<
|
||||
"configuration plus a migration file and devise routes."
|
||||
|
||||
def self.source_root
|
||||
@_devise_source_root ||= File.expand_path("../templates", __FILE__)
|
||||
end
|
||||
|
|
25
lib/generators/devise_install/devise_install_generator.rb
Normal file
25
lib/generators/devise_install/devise_install_generator.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
class DeviseInstallGenerator < Rails::Generators::Base
|
||||
desc "Creates a Devise initializer and copy locale files to your application."
|
||||
|
||||
def self.source_root
|
||||
@_devise_source_root ||= File.expand_path("../templates", __FILE__)
|
||||
end
|
||||
|
||||
def copy_initializer
|
||||
template "devise.rb", "config/initializers/devise.rb"
|
||||
end
|
||||
|
||||
def copy_locale
|
||||
copy_file "../../../../config/locales/en.yml", "config/locales/devise.en.yml"
|
||||
end
|
||||
|
||||
def show_readme
|
||||
readme "README"
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def readme(path)
|
||||
say File.read(File.expand_path(path, self.class.source_root))
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue