Class: HasPermalinkGenerator
- Inherits:
-
ActiveRecord::Generators::Base
- Object
- ActiveRecord::Generators::Base
- HasPermalinkGenerator
- Defined in:
- lib/generators/has_permalink_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #generate_migration ⇒ Object
- #migration_class_name ⇒ Object
- #migration_file_name ⇒ Object
- #migration_name ⇒ Object
Class Method Details
.source_root ⇒ Object
6 7 8 |
# File 'lib/generators/has_permalink_generator.rb', line 6 def self.source_root @source_root ||= File.('../templates', __FILE__) end |
Instance Method Details
#generate_migration ⇒ Object
10 11 12 |
# File 'lib/generators/has_permalink_generator.rb', line 10 def generate_migration migration_template "has_permalink_migration.rb.erb", "db/migrate/#{migration_file_name}" end |
#migration_class_name ⇒ Object
22 23 24 |
# File 'lib/generators/has_permalink_generator.rb', line 22 def migration_class_name migration_name.camelize end |
#migration_file_name ⇒ Object
18 19 20 |
# File 'lib/generators/has_permalink_generator.rb', line 18 def migration_file_name "#{migration_name}.rb" end |
#migration_name ⇒ Object
14 15 16 |
# File 'lib/generators/has_permalink_generator.rb', line 14 def migration_name "add_permalink_to_#{name.underscore}" end |