Understand design differences between Paperclip and Shrine
masterWhen transitioning from Paperclip to Shrine, note these fundamental architectural shifts:
- Uploader Logic: Paperclip configures attachments directly in models. Shrine encapsulates logic in dedicated
Uploaderclasses. - Storage: Paperclip couples storage configuration to the model. Shrine uses decoupled
Shrine.storagesobjects and supports a concept of 'temporary' (cache) storage. - Persistence: Paperclip uses multiple columns (
_file_name,_content_type, etc.). Shrine uses a single<name>_datacolumn containing a JSON object withid,storage, andmetadata. - Location: Paperclip stores only the filename and calculates paths dynamically. Shrine persists the full location in the JSON data, making it more resilient to configuration changes.
- Processing: Paperclip uses model-level styles. Shrine uses instance-level processing (e.g., via the
derivativesplugin), allowing for more control and agnostic processing tools (likelibvips via image_processing).