Sha256: ced5a55d95e408f97129003ec0a6f7d09d382c484859c41b3f7be4d509fb8177

Contents?: true

Size: 656 Bytes

Versions: 4

Compression:

Stored size: 656 Bytes

Contents

# The content of an {Article} can contain multiple pictures.
# Pictures are associated to an article through parsing the articles
# content and extracting the ids of the used images.

require 'carrierwave'
require 'carrierwave/orm/activerecord'

module Lines  
  class Picture < Lines::ApplicationRecord
    # Associations    
    belongs_to :article, touch: true

    # Mount carrierwave picture uploader
    mount_uploader :image, PictureUploader

    # Callbacks
    before_create :default_name

    # Returns the default name fo a picture
    def default_name
      self.name ||= File.basename(image.filename, '.*').titleize if image
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lines-engine-1.2.3 app/models/lines/picture.rb
lines-engine-1.2.2 app/models/lines/picture.rb
lines-engine-1.2.1.1 app/models/lines/picture.rb
lines-engine-1.2.1 app/models/lines/picture.rb