Class: AsktiveRecord::Generators::SetupGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- AsktiveRecord::Generators::SetupGenerator
- Defined in:
- lib/generators/asktive_record/setup_generator.rb
Overview
SetupGenerator is a Rails generator that sets up AsktiveRecord by reading the database schema and preparing it for the LLM. It attempts to dump the schema using ‘rails db:schema:dump` and reads the schema file or structure.sql to provide the schema context to the LLM.
Instance Method Summary collapse
Instance Method Details
#perform_setup ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/generators/asktive_record/setup_generator.rb', line 14 def perform_setup schema_path = AsktiveRecord.configuration&.db_schema_path || "db/schema.rb" schema_content = defined?(Rails) ? dump_and_read_schema(schema_path) : simulate_schema_read(schema_path) if schema_content puts "Database schema obtained. Length: #{schema_content.length} characters." puts "Next step would be to process and provide this schema to the configured LLM." else puts "Could not obtain database schema. LLM will not have schema context." end puts "AsktiveRecord setup process complete." puts "Ensure your LLM API key and other configurations are set in config/initializers/asktive_record.rb" end |