Class: RailsPageComment::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- RailsPageComment::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/rails_page_comment/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#copy_initializer ⇒ Object
copy configuration.
-
#create_migrations ⇒ Object
def create_models [:page_comment].each do |filename| template “##generator_dir/rails_page_comment/#filename.rb”, File.join(‘app/models’, rails_page_comment_dir, “#filename.rb”) end end.
- #mount_engine ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
15 16 17 |
# File 'lib/generators/rails_page_comment/install_generator.rb', line 15 def self.next_migration_number(dirname) Time.now.strftime("%Y%m%d%H%M%S") end |
.source_root ⇒ Object
11 12 13 |
# File 'lib/generators/rails_page_comment/install_generator.rb', line 11 def self.source_root @source_root ||= File.(File.join(File.dirname(__FILE__), 'templates')) end |
Instance Method Details
#copy_initializer ⇒ Object
copy configuration
20 21 22 |
# File 'lib/generators/rails_page_comment/install_generator.rb', line 20 def copy_initializer template "rails_page_comment.rb", "config/initializers/rails_page_comment.rb" end |
#create_migrations ⇒ Object
def create_models
[:page_comment].each do |filename|
template "#{generator_dir}/rails_page_comment/#{filename}.rb",
File.join('app/models', rails_page_comment_dir, "#{filename}.rb")
end
end
35 36 37 |
# File 'lib/generators/rails_page_comment/install_generator.rb', line 35 def create_migrations migration_template "#{generator_dir}/migration.rb", File.join('db/migrate', "create_rails_page_comment_page_comments.rb") end |
#mount_engine ⇒ Object
24 25 26 |
# File 'lib/generators/rails_page_comment/install_generator.rb', line 24 def mount_engine route "mount RailsPageComment::Engine => '/rails_page_comment'" end |