Workshop interest

This commit is contained in:
Godwin
2015-09-13 18:30:50 -07:00
parent a90c465160
commit a0fbbc9f4f
88 changed files with 2067 additions and 819 deletions
+13
View File
@@ -35,6 +35,19 @@ class Workshop < ActiveRecord::Base
creator?(user)
end
def can_show_interest?(user)
!facilitator?(user)
end
def interested?(user)
user.present? && !!WorkshopInterest.find_by(workshop_id: id, user_id: user.id)
end
def interested_count
workshops = WorkshopInterest.where(:workshop_id => id)
workshops ? workshops.size : 0
end
private
def make_slug
if !self.slug
+4
View File
@@ -0,0 +1,4 @@
class WorkshopInterest < ActiveRecord::Base
belongs_to :workshop
has_one :user
end