Class: Boss::Resource

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Pagination
Defined in:
app/models/boss/resource.rb

Constant Summary collapse

@@allowed_image_formats =
["image/jpeg", "image/gif", "image/png"]

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from Pagination

get_class_name, included

Instance Attribute Details

Returns the value of attribute banner.



8
9
10
# File 'app/models/boss/resource.rb', line 8

def banner
  @banner
end

Class Method Details

.all_imagesObject



37
38
39
# File 'app/models/boss/resource.rb', line 37

def all_images
  where("extension in (?)", ["jpeg","jpg","gif","png"])
end

.create_file(file_info) ⇒ Object



33
34
35
# File 'app/models/boss/resource.rb', line 33

def create_file(file_info)
  Boss::Resource.create(:resource => file_info)
end

.create_image(image_info) ⇒ Object

Only creates the image if it the mime type is allowed. This is not done in validates_attachment in order to allow any kind of resource, not only images



29
30
31
# File 'app/models/boss/resource.rb', line 29

def create_image(image_info)
  @@allowed_image_formats.include?(image_info.content_type) ? Boss::Resource.create(:resource => image_info) : false
end