Class: Ckeditor::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Ckeditor::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/ckeditor/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#copy_initializer ⇒ Object
copy configuration.
- #create_migration ⇒ Object
- #create_models ⇒ Object
- #mount_engine ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
22 23 24 |
# File 'lib/generators/ckeditor/install_generator.rb', line 22 def self.next_migration_number(dirname) Time.now.strftime("%Y%m%d%H%M%S") end |
.source_root ⇒ Object
18 19 20 |
# File 'lib/generators/ckeditor/install_generator.rb', line 18 def self.source_root @source_root ||= File.(File.join(File.dirname(__FILE__), 'templates')) end |
Instance Method Details
#copy_initializer ⇒ Object
copy configuration
27 28 29 30 31 32 33 |
# File 'lib/generators/ckeditor/install_generator.rb', line 27 def copy_initializer template "ckeditor.rb", "config/initializers/ckeditor.rb" if backend == "dragonfly" template File.join("base", "dragonfly", "initializer.rb"), "config/initializers/ckeditor_dragonfly.rb" end end |
#create_migration ⇒ Object
54 55 56 57 58 |
# File 'lib/generators/ckeditor/install_generator.rb', line 54 def create_migration if ["active_record"].include?(orm) migration_template "#{generator_dir}/migration.rb", File.join('db/migrate', "create_ckeditor_assets.rb") end end |
#create_models ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/generators/ckeditor/install_generator.rb', line 39 def create_models [:asset, :picture, :attachment_file].each do |filename| template "#{generator_dir}/ckeditor/#{filename}.rb", File.join('app/models', ckeditor_dir, "#{filename}.rb") end if backend == "carrierwave" template "#{uploaders_dir}/uploaders/ckeditor_attachment_file_uploader.rb", File.join("app/uploaders", "ckeditor_attachment_file_uploader.rb") template "#{uploaders_dir}/uploaders/ckeditor_picture_uploader.rb", File.join("app/uploaders", "ckeditor_picture_uploader.rb") end end |
#mount_engine ⇒ Object
35 36 37 |
# File 'lib/generators/ckeditor/install_generator.rb', line 35 def mount_engine route "mount Ckeditor::Engine => '/ckeditor'" end |