class UserNotif::NotifsController

Public Instance Methods

read() click to toggle source
# File lib/generators/user_notif/install_templates/notifs_controller.rb, line 6
def read
  set_notif
  raise ActiveRecord::RecordNotFound, 'Not Found' unless @notif
  @notif.update!(unread: false)
  head :ok
end

Private Instance Methods

authorized?() click to toggle source
# File lib/generators/user_notif/install_templates/notifs_controller.rb, line 19
def authorized?
  # This method assumes you are using Devise. You can change it to use your custom logic.
  raise ActiveRecord::RecordNotFound, 'Not Found' unless @notif.owner == current_user
end
set_notif() click to toggle source
# File lib/generators/user_notif/install_templates/notifs_controller.rb, line 15
def set_notif
  @notif = UserNotif::Notif.find(params[:id].to_i)
end