2014-02-09 07:54:03 +00:00
|
|
|
class Resource < ActiveRecord::Base
|
2014-02-14 08:09:16 +00:00
|
|
|
attr_accessible :supercategory, :user_id, :resource_category_id, :name, :serial, :specs, :status, :donatable,
|
|
|
|
:picture, :picture_file_name, :picture_content_type, :picture_file_size, :picture_updated_at,
|
|
|
|
:picture2, :picture2_file_name, :picture2_content_type, :picture2_file_size, :picture2_updated_at,
|
|
|
|
:picture3, :picture3_file_name, :picture3_content_type, :picture3_file_size, :picture3_updated_at,
|
|
|
|
:picture4, :picture4_file_name, :picture4_content_type, :picture4_file_size, :picture4_updated_at,
|
|
|
|
:notes, :estimated_value, :disposed_at, :modified_by
|
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-14 07:02:11 +00:00
|
|
|
belongs_to :resource_category
|
2014-02-14 08:09:16 +00:00
|
|
|
|
|
|
|
PICTURE_OPTIONS = { :styles => { :medium => "300x300>",
|
|
|
|
:thumb => "100x100>",
|
|
|
|
:tiny => "50x50>"},
|
|
|
|
:storage => :s3,
|
2014-04-11 06:20:50 +00:00
|
|
|
:s3_protocol => :https,
|
2014-03-03 02:06:39 +00:00
|
|
|
:s3_credentials => { :access_key_id => ENV['S3_KEY'],
|
|
|
|
:secret_access_key => ENV['S3_SECRET'] },
|
2014-02-14 08:09:16 +00:00
|
|
|
:path => ":attachment/:id/:style.:extension",
|
2014-03-03 02:06:39 +00:00
|
|
|
:bucket => ENV['S3_BUCKET'] }
|
2014-02-14 08:09:16 +00:00
|
|
|
|
2014-03-03 02:06:39 +00:00
|
|
|
has_attached_file :picture, PICTURE_OPTIONS
|
2014-02-14 08:09:16 +00:00
|
|
|
has_attached_file :picture2, PICTURE_OPTIONS
|
|
|
|
has_attached_file :picture3, PICTURE_OPTIONS
|
|
|
|
has_attached_file :picture4, PICTURE_OPTIONS
|
2014-02-09 09:08:08 +00:00
|
|
|
|
2014-02-14 07:02:11 +00:00
|
|
|
def resource_category_name
|
|
|
|
resource_category.name if resource_category
|
2014-02-09 09:08:08 +00:00
|
|
|
end
|
2014-02-09 07:54:03 +00:00
|
|
|
end
|