Class: FiatNotifications::SubscriptionsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/fiat_notifications/notifications_controller.rb

Instance Method Summary collapse

Instance Method Details

#mark_all_readObject



24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/fiat_notifications/notifications_controller.rb', line 24

def mark_all_read
  @user = User.find(params[:user_id])
  @user.notifications.shown.each do |m|
    m.update_attributes(hidden: 1)
  end

  respond_to do |format|
    format.html { redirect_back(fallback_location: notifications_system_user_path(@user), notice: "Notifications marked as read." ) }
  end
end

#updateObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/fiat_notifications/notifications_controller.rb', line 4

def update
  @notification = Notification.find(params[:id])

  sibling_notifications = Notification.shown.where(notifiable_type: @notification.notifiable_type, notifiable_id: @notification.notifiable_id, recipient_id: params[:user_id])

  sibling_notifications.each do |notification|
    notification.update_attributes(hidden: 1)
  end

  respond_to do |format|
    if @notification.notifiable_type == "Message"
      if current_user_sim.internal
        format.html { redirect_to system_message_path(@notification.notifiable_id) }
      else
        format.html { redirect_to client_message_path(@notification.notifiable_id) }
      end
    end
  end
end