Class: Koi::ActiveRecordGenerator
- Inherits:
-
ActiveRecord::Generators::ModelGenerator
- Object
- ActiveRecord::Generators::ModelGenerator
- Koi::ActiveRecordGenerator
- Defined in:
- lib/generators/koi/active_record/active_record_generator.rb
Instance Method Summary collapse
Instance Method Details
#admin_search ⇒ Object
9 10 11 |
# File 'lib/generators/koi/active_record/active_record_generator.rb', line 9 def admin_search "PgSearch::Model".safe_constantize ? pg_search : sql_search end |
#ordinal_scope ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/generators/koi/active_record/active_record_generator.rb', line 13 def ordinal_scope return unless attributes.any? { |attr| attr.name == "ordinal" } insert_into_file "app/models/#{file_path}.rb", before: /end\Z/ do <<~RUBY default_scope -> { order(ordinal: :asc) } RUBY end end |