Class: Cable::Generators::MediaGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Cable::Generators::MediaGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/cable/media/media_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Implement the required interface for Rails::Generators::Migration.
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
25 26 27 28 29 30 31 |
# File 'lib/generators/cable/media/media_generator.rb', line 25 def self.next_migration_number(dirname) if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#create_model ⇒ Object
19 20 21 |
# File 'lib/generators/cable/media/media_generator.rb', line 19 def create_model template 'model.rb' , "app/models/#{model_name}.rb" end |
#create_table ⇒ Object
13 14 15 16 17 |
# File 'lib/generators/cable/media/media_generator.rb', line 13 def create_table if .install? migration_template 'migration.rb', "db/migrate/create_cable_media_assets.rb" end end |