You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
745 B
31 lines
745 B
class Organization < ActiveRecord::Base
|
|
mount_uploader :logo, LogoUploader
|
|
mount_uploader :avatar, AvatarUploader
|
|
mount_uploader :cover, CoverUploader
|
|
|
|
has_many :locations_organization
|
|
has_many :locations, :through => :locations_organization
|
|
|
|
has_many :user_organization_relationships, :dependent => :destroy
|
|
has_many :users, :through => :user_organization_relationships
|
|
|
|
accepts_nested_attributes_for :locations, :reject_if => proc {|l| l[id].blank?}
|
|
accepts_nested_attributes_for :user_organization_relationships, :reject_if => proc {|u| u[:user_id].blank?}, :allow_destroy => true
|
|
|
|
def location
|
|
locations.first
|
|
end
|
|
|
|
def longitude
|
|
location.longitude
|
|
end
|
|
|
|
def latitude
|
|
location.latitude
|
|
end
|
|
|
|
def to_param
|
|
slug
|
|
end
|
|
|
|
end
|
|
|