Class: LoudmouthGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- LoudmouthGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/loudmouth/loudmouth_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
-
.source_root ⇒ Object
FIXME: Put in argument validation to assure that the models are in singular form or things break.
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration. taken from github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
18 19 20 21 22 23 24 25 |
# File 'lib/generators/loudmouth/loudmouth_generator.rb', line 18 def self.next_migration_number(dirname) next_migration_number = current_migration_number(dirname) + 1 if ActiveRecord::Base. [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max else "%.3d" % next_migration_number end end |
.source_root ⇒ Object
FIXME: Put in argument validation to assure that the models are in singular form or things break.
12 13 14 |
# File 'lib/generators/loudmouth/loudmouth_generator.rb', line 12 def self.source_root @source_root ||= File.join(File.dirname(__FILE__), 'templates') end |
Instance Method Details
#create_groups_migration_file ⇒ Object
27 28 29 |
# File 'lib/generators/loudmouth/loudmouth_generator.rb', line 27 def create_groups_migration_file migration_template 'comments_migration.rb', "db/migrate/create_#{topic_model.downcase}_comments.rb" end |
#create_model_files ⇒ Object
31 32 33 |
# File 'lib/generators/loudmouth/loudmouth_generator.rb', line 31 def create_model_files template 'comment_model.rb', "app/models/#{topic_model.downcase}_comment.rb" end |