Class: Blacklight::Allmaps::ModelsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Blacklight::Allmaps::ModelsGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/blacklight/allmaps/models_generator.rb
Instance Method Summary collapse
-
#copy_migrations ⇒ Object
Setup the database migrations.
- #include_sidecar_allmaps_solrdocument ⇒ Object
Instance Method Details
#copy_migrations ⇒ Object
Setup the database migrations
20 21 22 |
# File 'lib/generators/blacklight/allmaps/models_generator.rb', line 20 def copy_migrations rake "blacklight_allmaps_engine:install:migrations" end |
#include_sidecar_allmaps_solrdocument ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/generators/blacklight/allmaps/models_generator.rb', line 24 def include_sidecar_allmaps_solrdocument sidecar = <<-SIDECAR def sidecar_allmaps # Find or create, and set version sidecar = Blacklight::Allmaps::Sidecar.where( solr_document_id: id, ).first_or_create do |sc| sc.solr_version = self._source["_version_"] end sidecar.solr_version = self._source["_version_"] sidecar.save sidecar end SIDECAR inject_into_file "app/models/solr_document.rb", sidecar, before: /^end/ end |