b0deafc53e
* all the good changes * follows * dont send duplicates * remove follow_type for now * dont add all the extra stuff we're not implementing yet * refactor * lots of fixes * Delete activity.html.erb * Delete activity.text.erb * Update 20170209215819_create_follows.rb * Update schema.rb * Update mapping.rb * Update mailboxer.rb
21 lines
576 B
Ruby
21 lines
576 B
Ruby
# frozen_string_literal: true
|
|
class Star < ActiveRecord::Base
|
|
belongs_to :user
|
|
belongs_to :map
|
|
validates :map, uniqueness: { scope: :user, message: 'You have already starred this map' }
|
|
|
|
#after_create :after_created_async
|
|
#before_destroy :before_destroyed
|
|
|
|
protected
|
|
|
|
def after_created_async
|
|
FollowService.follow(map, user, 'starred')
|
|
NotificationService.notify_followers(map, 'map_starred', self, 'created')
|
|
end
|
|
handle_asynchronously :after_created_async
|
|
|
|
def before_destroyed
|
|
FollowService.remove_reason(map, user, 'starred')
|
|
end
|
|
end
|