Class: Redactor::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Redactor::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/redactor/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
19 20 21 |
# File 'lib/generators/redactor/install_generator.rb', line 19 def self.next_migration_number(dirname) Time.now.strftime("%Y%m%d%H%M%S") end |
.source_root ⇒ Object
15 16 17 |
# File 'lib/generators/redactor/install_generator.rb', line 15 def self.source_root @source_root ||= File.(File.join(File.dirname(__FILE__), 'templates')) end |
Instance Method Details
#create_migration ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/generators/redactor/install_generator.rb', line 41 def create_migration if orm.to_s == "active_record" if ARGV.include?('--devise') migration_template "#{generator_dir}/devise_migration.rb", File.join('db/migrate', "create_redactor_assets.rb") else migration_template "#{generator_dir}/migration.rb", File.join('db/migrate', "create_redactor_assets.rb") end end end |
#create_models ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/redactor/install_generator.rb', line 27 def create_models [:asset, :picture, :document].each do |filename| template "#{generator_dir}/redactor/#{filename}.rb", File.join('app/models', redactor_dir, "#{filename}.rb") end if backend == "carrierwave" [:picture, :document].each do |filename| template "#{uploaders_dir}/uploaders/redactor_rails_#{filename}_uploader.rb", File.join("app/uploaders", "redactor_rails_#{filename}_uploader.rb") end end end |
#mount_engine ⇒ Object
23 24 25 |
# File 'lib/generators/redactor/install_generator.rb', line 23 def mount_engine route "mount RedactorRails::Engine => '/redactor_rails'" end |