File tree Expand file tree Collapse file tree 2 files changed +7
-21
lines changed
lib/active_scaffold/bridges Expand file tree Collapse file tree 2 files changed +7
-21
lines changed Original file line number Diff line number Diff line change 11class ActiveScaffold ::Bridges ::ActiveStorage < ActiveScaffold ::DataStructures ::Bridge
22 def self . install
3- if ActiveScaffold ::Config ::Core . method_defined? ( :initialize_with_active_storage )
4- raise "We've detected that you have active_scaffold_active_storage_bridge installed. This plugin has been moved to core. Please remove active_scaffold_active_storage_bridge to prevent any conflicts"
5- end
6- require File . join ( File . dirname ( __FILE__ ) , 'active_storage/active_storage_bridge' )
7- require File . join ( File . dirname ( __FILE__ ) , 'active_storage/form_ui' )
8- require File . join ( File . dirname ( __FILE__ ) , 'active_storage/list_ui' )
9- require File . join ( File . dirname ( __FILE__ ) , 'active_storage/active_storage_helpers' )
3+ Dir [ File . join ( __dir__ , 'active_storage' , '*.rb' ) ] . each { |file | require file }
104 ActiveScaffold ::Config ::Core . send :prepend , ActiveScaffold ::Bridges ::ActiveStorage ::ActiveStorageBridge
115 end
126end
Original file line number Diff line number Diff line change @@ -14,25 +14,17 @@ def initialize(model_id)
1414 update . multipart = true
1515 create . multipart = true
1616
17- model . active_storage_has_one_fields . each { |field | configure_active_storage_has_one_field ( field . to_sym ) }
18- model . active_storage_has_many_fields . each { |field | configure_active_storage_has_many_field ( field . to_sym ) }
17+ model . active_storage_has_one_fields . each { |field | configure_active_storage_field ( field . to_sym , :has_one ) }
18+ model . active_storage_has_many_fields . each { |field | configure_active_storage_field ( field . to_sym , :has_many ) }
1919 end
2020
2121 private
2222
23- def configure_active_storage_has_one_field ( field )
23+ def configure_active_storage_field ( field , field_type )
2424 columns << field
25- columns . exclude "#{ field } _attachment" . to_sym
26- columns . exclude "#{ field } _blob" . to_sym
27- columns [ field ] . form_ui ||= :active_storage_has_one
28- columns [ field ] . params . add "delete_#{ field } "
29- end
30-
31- def configure_active_storage_has_many_field ( field )
32- columns << field
33- columns . exclude "#{ field } _attachments" . to_sym
34- columns . exclude "#{ field } _blobs" . to_sym
35- columns [ field ] . form_ui ||= :active_storage_has_many
25+ columns . exclude ( field_type == :has_many ? "#{ field } _attachments" : "#{ field } _attachment" ) . to_sym
26+ columns . exclude ( field_type == :has_many ? "#{ field } _blobs" : "#{ field } _blob" ) . to_sym
27+ columns [ field ] . form_ui ||= "active_storage_#{ field_type } " . to_sym
3628 columns [ field ] . params . add "delete_#{ field } "
3729 end
3830 end
You can’t perform that action at this time.
0 commit comments