Sha256: 1b91509b50b21756078188e3d687f34a20282e78e14167a0e646b78973759a32

Contents?: true

Size: 955 Bytes

Versions: 18

Compression:

Stored size: 955 Bytes

Contents

# == Schema Information
#
# Table name: alchemy_essence_files
#
#  id            :integer          not null, primary key
#  attachment_id :integer
#  title         :string(255)
#  css_class     :string(255)
#  creator_id    :integer
#  updater_id    :integer
#  created_at    :datetime         not null
#  updated_at    :datetime         not null
#

module Alchemy
  class EssenceFile < ActiveRecord::Base
    belongs_to :attachment
    acts_as_essence ingredient_column: 'attachment'

    def attachment_url
      return if attachment.nil?
      routes.download_attachment_path(id: attachment.id, name: attachment.file_name)
    end

    def preview_text(max=30)
      return "" if attachment.blank?
      attachment.name.to_s[0..max-1]
    end

    # Returns a serialized ingredient value for json api
    def serialized_ingredient
      attachment_url
    end

    private

    def routes
      @routes ||= Engine.routes.url_helpers
    end

  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
alchemy_cms-3.2.1 app/models/alchemy/essence_file.rb
alchemy_cms-3.1.3 app/models/alchemy/essence_file.rb
lc_alchemy_cms-3.2.1 app/models/alchemy/essence_file.rb
lc_alchemy_cms-3.2.0 app/models/alchemy/essence_file.rb
alchemy_cms-3.2.0 app/models/alchemy/essence_file.rb
alchemy_cms-3.2.0.rc1 app/models/alchemy/essence_file.rb
alchemy_cms-3.2.0.beta app/models/alchemy/essence_file.rb
alchemy_cms-3.1.1 app/models/alchemy/essence_file.rb
alchemy_cms-3.1.0 app/models/alchemy/essence_file.rb
alchemy_cms-3.1.0.rc3 app/models/alchemy/essence_file.rb
alchemy_cms-3.1.0.rc2 app/models/alchemy/essence_file.rb
alchemy_cms-3.1.0.rc1 app/models/alchemy/essence_file.rb
alchemy_cms-3.1.0.beta6 app/models/alchemy/essence_file.rb
alchemy_cms-3.1.0.beta5 app/models/alchemy/essence_file.rb
alchemy_cms-3.1.0.beta4 app/models/alchemy/essence_file.rb
alchemy_cms-3.1.0.beta3 app/models/alchemy/essence_file.rb
alchemy_cms-3.1.0.beta2 app/models/alchemy/essence_file.rb
alchemy_cms-3.1.0.beta1 app/models/alchemy/essence_file.rb