Sha256: 38435a0d9a6c91b45c1c82f660987127ed1ca5a0656469b93856305c19989063
Contents?: true
Size: 1.25 KB
Versions: 1
Compression:
Stored size: 1.25 KB
Contents
module ActiveScaffold module Bridges class ActiveStorage module ActiveStorageBridge 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 private def configure_active_storage_field(field, field_type) columns << field columns.exclude "#{field}_attachment#{'s' if field_type == :has_many}".to_sym columns.exclude "#{field}_blob#{'s' if field_type == :has_many}".to_sym columns[field].form_ui ||= "active_storage_#{field_type}".to_sym columns[field].params.add "delete_#{field}" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_scaffold-3.6.0.rc1 | lib/active_scaffold/bridges/active_storage/active_storage_bridge.rb |