Sha256: 3f2472d5f2d91d9457c053084750ed33844427e1f03d6578d3be566403d8767c
Contents?: true
Size: 995 Bytes
Versions: 1
Compression:
Stored size: 995 Bytes
Contents
require "rails/generators/active_record" module Autosuggest module Generators class SuggestionsGenerator < Rails::Generators::Base include ActiveRecord::Generators::Migration source_root File.join(__dir__, "templates") def copy_templates template "model.rb", "app/models/autosuggest/suggestion.rb" migration_template "migration.rb", "db/migrate/create_autosuggest_suggestions.rb", migration_version: migration_version end def migration_version "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" end def mysql? adapter =~ /mysql/i end # use connection_config instead of connection.adapter # so database connection isn't needed def adapter if ActiveRecord::VERSION::STRING.to_f >= 6.1 ActiveRecord::Base.connection_db_config.adapter.to_s else ActiveRecord::Base.connection_config[:adapter].to_s end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
autosuggest-0.2.0 | lib/generators/autosuggest/suggestions_generator.rb |