identified_by :current_user def connect self.current_user = find_verified_user end protected def find_verified_user if current_user = User.find(cookies.signed[:user_id]) current_user else reject_unauthorized_connection end end end end
current_user.appear end def unsubscribed current_user.disappear end def appear(data) current_user.appear on: data['appearing_on'] end def away current_user.away end end
# Called once the subscription has been successfully completed rejected: -> # Called when the subscription is rejected by the server appear: -> @perform 'appear', appearing_on: @appearingOn() away: -> @perform 'away' appearingOn: -> $('main').data 'appearing-on' $(document).on 'page:change', -> App.appearance.appear() $(document).on 'click', '[data-behavior~=appear_away]', -> App.appearance.away() false
# Called once the subscription has been successfully completed rejected: -> # Called when the subscription is rejected by the server appear: -> @perform 'appear', appearing_on: @appearingOn() away: -> @perform 'away' appearingOn: -> $('main').data 'appearing-on' $(document).on 'page:change', -> App.appearance.appear() $(document).on 'click', '[data-behavior~=appear_away]', -> App.appearance.away() false