Class: DatashiftJourney::CollectorGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- DatashiftJourney::CollectorGenerator
- Extended by:
- GenerateCommon
- Includes:
- GenerateCommon, Rails::Generators::Migration
- Defined in:
- lib/generators/datashift_journey/collector/collector_generator.rb
Instance Method Summary collapse
Methods included from GenerateCommon
journey_plan_filename, model_path, next_migration_number
Instance Method Details
#create_collector ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/generators/datashift_journey/collector/collector_generator.rb', line 15 def create_collector @migration_version = '6.1' # TODO: how can we get this dynamically from Rails version ? migration_template 'collector_migration.rb', 'db/migrate/datashift_journey_create_collector.rb'#, migration_version: migration_version code = <<-EOS has_many :data_nodes, class_name: 'DatashiftJourney::Collector::DataNode', as: :plan, foreign_key: :plan_id, dependent: :destroy accepts_nested_attributes_for :data_nodes EOS inject_into_file model_path, :after => /class.* < ApplicationRecord/ do "\n#{code}" end route(%( # This mounts Datashift Journey's Collector routes # scope :api, constraints: { format: 'json' } do scope :v1 do resources :page_states, only: [:create], controller: 'datashift_journey/page_states' end end ) ) end |