This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AttachedValidator < ActiveModel::EachValidator | |
# Active Storage validator to ensure that an attachment is attached. | |
# | |
# usage: | |
# validates :upload, attached: true | |
# | |
def validate_each(record, attribute, _value) | |
return if record.send(attribute).attached? | |
errors_options = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /app/models/concerns/has_many_attached.rb | |
module HasManyAttached | |
extend ActiveSupport::Concern | |
class_methods do | |
def has_many_attached(name, dependent: :purge_later, service: nil, strict_loading: false, **options) | |
super(name, dependent: :purge_later, service: nil, strict_loading: false) | |
if options[:file_types].any? | |
validate "validate_#{name}_file_types".to_sym |
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
HISTOIRE;UNIVERS;Typo Body Size (px);Typo Body interlignage (px);C;M;J;N;COULEUR;ILLUSTRATRICE;AUTEUR;ASSETS - ILLUSTRATIONS;ASSETS - COUV-2&3 (TOUJOURS PAREIL);ASSETS - COUV 4 (RANDOM 5 IMG) - même univers;DÉFINITIONS | |
Le Merveilleux;Écriture Libre;16;24;0;34;50;0;#FFBB87;Irène Bonacina;-;https://drive.google.com/drive/u/1/folders/1VBcX6Uzub6hmPxL-qTJICs-ZSbpEid5c;https://drive.google.com/drive/u/1/folders/1uwiGzQ_5AWREAPiZShx9jXi6Vp_XrY3X;https://drive.google.com/drive/u/1/folders/1hDEYxZiqNeuDzaol1_OEREYXWX9keeLr;NON | |
La Science Fiction;Écriture Libre;16;24;50;57;12;0;#9378A7;Taty Vovchek;-;https://drive.google.com/drive/u/1/folders/1RDSlVztEvTsO44Vt2uz_8vne0S6U6fdd;https://drive.google.com/drive/u/1/folders/1uwiGzQ_5AWREAPiZShx9jXi6Vp_XrY3X;https://drive.google.com/drive/u/1/folders/1hDEYxZiqNeuDzaol1_OEREYXWX9keeLr;NON | |
La Bergère et le Ramoneur;Forêt Enchantée;19;29;0;32;84;0;#FFAD29;Irène Bonacina;Hans Christian Andersen;https://drive.google.com/drive/folders/1Hzw7zF5qSyw3H1qU_SBFLy_NH9KSeqmE?usp=sharing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'prawn' | |
require 'prawn/measurements' | |
# I have a small collection of links to the resources I used to figure all | |
# this out: http://pinboard.in/u:fidothe/t:pdfx | |
module PDFX | |
class PageBox | |
include Prawn::Measurements | |
attr_reader :bleed_mm |