Class: Boss::Resource
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Boss::Resource
- 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
-
#banner ⇒ Object
Returns the value of attribute banner.
Class Method Summary collapse
- .all_images ⇒ Object
- .create_file(file_info) ⇒ Object
-
.create_image(image_info) ⇒ Object
Only creates the image if it the mime type is allowed.
Methods included from Pagination
Instance Attribute Details
#banner ⇒ Object
Returns the value of attribute banner.
8 9 10 |
# File 'app/models/boss/resource.rb', line 8 def @banner end |
Class Method Details
.all_images ⇒ Object
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 |