2014-02-09 07:54:03 +00:00
|
|
|
class Resource < ActiveRecord::Base
|
2014-02-09 11:32:45 +00:00
|
|
|
attr_accessible :supercategory, :user_id, :category_id, :name, :serial, :specs, :status, :donatable, :picture, :picture_file_name, :picture_content_type, :picture_file_size, :picture_updated_at, :notes, :estimated_value, :disposed_at
|
2014-02-09 10:42:17 +00:00
|
|
|
|
2014-02-09 09:08:08 +00:00
|
|
|
belongs_to :owner, :class_name => "ToolshareUser" #TODO: remove owner
|
|
|
|
belongs_to :user
|
2014-02-09 07:54:03 +00:00
|
|
|
belongs_to :category, :class_name => "ResourceCategory"
|
2014-02-09 09:08:08 +00:00
|
|
|
has_attached_file :picture, #TODO: move to local storage
|
2014-02-09 07:54:03 +00:00
|
|
|
:styles => { :medium => "300x300>",
|
|
|
|
:thumb => "100x100>",
|
|
|
|
:tiny => "50x50>"},
|
|
|
|
:storage => :s3,
|
|
|
|
:s3_credentials => Rails.root.join('config', 's3.yml'),
|
|
|
|
:path => ":attachment/:id/:style.:extension",
|
|
|
|
:bucket => 'Toolshare'
|
2014-02-09 09:08:08 +00:00
|
|
|
|
|
|
|
def category_name
|
|
|
|
self.category.name if self.category
|
|
|
|
end
|
2014-02-09 07:54:03 +00:00
|
|
|
end
|