Sha256: d8a2df06aacb0a079db6f31382f1fead5249a05ccc10845dc0dc770fd77146fc

Contents?: true

Size: 910 Bytes

Versions: 28

Compression:

Stored size: 910 Bytes

Contents

class Resource < ActiveRecord::Base
    
  has_attachment :storage => :file_system,
		      :size => 0.kilobytes..50.megabytes,
          :path_prefix => 'public/system/resources'

  acts_as_indexed :fields => [:title, :type_of_content]

  def validate
    errors.add_to_base("You must choose a file to upload") unless self.filename
    
    unless self.filename.nil?
      [:size].each do |attr_name|
        enum = attachment_options[attr_name]
        unless enum.nil? || enum.include?(send(attr_name))
          errors.add_to_base("Files should be smaller than 50 MB in size")
        end
      end
    end
    
  end
  
  # used for searching
  def type_of_content
    self.content_type.split("/").join(" ")
  end

	def title
		(split_filename = self[:filename].split('.')).pop and return split_filename.join('.').titleize
	end

	def self.per_page(dialog = false)
	  size = (dialog ? 12 : 20)
  end
  
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
refinerycms-0.9.5.13 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.12 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.11 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.10 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.9 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.8 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.7 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.6 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.5 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.4 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.3 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.2 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5.1 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.5 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.4.5 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.4.4 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.4.3 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.4.2 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.4.1 vendor/plugins/resources/app/models/resource.rb
refinerycms-0.9.4 vendor/plugins/resources/app/models/resource.rb