Module: ActiveScaffold::Bridges::ActiveStorage::ActiveStorageBridge

Defined in:
lib/active_scaffold/bridges/active_storage/active_storage_bridge.rb

Instance Method Summary collapse

Instance Method Details

#initialize(model_id) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/active_scaffold/bridges/active_storage/active_storage_bridge.rb', line 5

def initialize(model_id)
  super
  return unless ActiveScaffold::Bridges::ActiveStorage::ActiveStorageBridgeHelpers.klass_has_active_storage_fields?(model)

  model.send :extend, ActiveScaffold::Bridges::ActiveStorage::ActiveStorageBridgeHelpers

  # include the "delete" helpers for use with active scaffold, unless they are already included
  model.generate_delete_helpers

  update.multipart = true
  create.multipart = true

  model.active_storage_has_one_fields.each { |field| configure_active_storage_field(field.to_sym, :has_one) }
  model.active_storage_has_many_fields.each { |field| configure_active_storage_field(field.to_sym, :has_many) }
end