Method: FulltextSearchableGenerator#create_migration_file
- Defined in:
- lib/rails/generators/fulltext_searchable/fulltext_searchable_generator.rb
#create_migration_file ⇒ Object
Every method that is declared below will be automatically executed when the generator is run
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rails/generators/fulltext_searchable/fulltext_searchable_generator.rb', line 22 def create_migration_file f = File.open File.join(File.dirname(__FILE__), 'templates', 'schema.rb') schema = f.read; f.close schema.gsub!(/ActiveRecord::Schema.*\n/, '') schema.gsub!(/^end\n*$/, '') f = File.open File.join(File.dirname(__FILE__), 'templates', 'migration.rb') migration = f.read; f.close migration.gsub!(/SCHEMA_AUTO_INSERTED_HERE/, schema) tmp = File.open "tmp/~migration_ready.rb", "w" tmp.write migration tmp.close migration_template File.(tmp.path), 'db/migrate/create_fulltext_indices_table.rb' remove_file 'tmp/~migration_ready.rb' end |