Class: ModelFromSqlGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ModelFromSqlGenerator
- Defined in:
- lib/support/model_from_sql/model_from_sql_generator.rb
Instance Method Summary collapse
Instance Method Details
#build_models ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/support/model_from_sql/model_from_sql_generator.rb', line 4 def build_models tables = ActiveRecord::Base.connection.tables tables.each do |table_name| generate "model #{table_name} --skip-migration" # or whatever you want here model_file = "app/models/#{table_name.singularize}.rb" inject_into_file model_file, before: "end\n" do "self.table_name = table_name_replace\n RUBY\n end\n gsub_file model_file, 'table_name_replace', table_name\n end\n\nend\n" |