Class: FriendshipGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- FriendshipGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/friendship/friendship_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.next_migration_number ⇒ Object
7 8 9 10 |
# File 'lib/generators/friendship/friendship_generator.rb', line 7 def self.next_migration_number now = DateTime.now "#{now.year}#{'%02d' % now.month}#{'%02d' % now.day}#{'%02d' % now.hour}#{'%02d' % now.minute}#{'%02d' % now.second}" end |
.source_root ⇒ Object
12 13 14 |
# File 'lib/generators/friendship/friendship_generator.rb', line 12 def self.source_root @source_root ||= File.(File.join(File.dirname(__FILE__), 'templates')) end |
Instance Method Details
#create_friendship_model_files ⇒ Object
17 18 19 20 |
# File 'lib/generators/friendship/friendship_generator.rb', line 17 def create_friendship_model_files template 'friendship.rb', 'app/models/friendship.rb' template 'create_friendships.rb', "db/migrate/#{self.class.next_migration_number}_create_friendships.rb" end |