class SimpleForm::FormBuilder
def file_method?(attribute_name)
- `#{attribute_name}_file_name` - Paperclip ~> `2.0` (added for backwards compatibility)
- `#{attribute_name}_attacher` - Refile >= `0.4.0` and Shrine >= `0.9.0`
- `remote_#{attribute_name}_url` - Refile >= `0.3.0` and CarrierWave >= `0.2.2`
- `#{attribute_name}_attachment` - ActiveStorage >= `5.2` and Refile >= `0.2.0` <= `0.4.0`
The order here was chosen based on the popularity of Gems:
Note: This does not support multiple file upload inputs, as this is very application-specific.
of their methods using `#respond_to?`.
This method tries to guess if an attribute belongs to some of these Gems by checking the presence
Most upload Gems add some kind of attributes to the ActiveRecord's model they are included in.
Internal: Try to discover whether an attribute corresponds to a file or not.
def file_method?(attribute_name) @object.respond_to?("#{attribute_name}_attachment") || @object.respond_to?("#{attribute_name}_attachments") || @object.respond_to?("remote_#{attribute_name}_url") || @object.respond_to?("#{attribute_name}_attacher") || @object.respond_to?("#{attribute_name}_file_name") end