Class: NotificationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- NotificationsController
- Includes:
- NotificationsHelper
- Defined in:
- lib/generators/notifykit/templates/app/controllers/notifications_controller.rb
Instance Method Summary collapse
- #cancel ⇒ Object
- #click ⇒ Object
- #ignore ⇒ Object
- #read ⇒ Object
- #recent ⇒ Object
- #unsubscribe ⇒ Object
- #view ⇒ Object
Instance Method Details
#cancel ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 63 def cancel notification.cancel respond_to do |format| format.json { head :no_content } format.html { redirect_to root_url } end end |
#click ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 25 def click trackable.click # To prevent a bare redirect, validate that the redirect url # was generated when the email was sent target_url = params[:r] target_url = root_url if trackable.email_urls.blank? || !trackable.email_urls.split("\n").index(target_url) respond_to do |format| format.json { head :no_content } format.html { redirect_to append_tracking_params(target_url) } end end |
#ignore ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 54 def ignore notification.ignore respond_to do |format| format.json { head :no_content } format.html { redirect_to root_url } end end |
#read ⇒ Object
39 40 41 42 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 39 def read trackable.read respond_with_no_content end |
#recent ⇒ Object
12 13 14 15 16 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 12 def recent respond_to do |format| format.json { render json: recent_notifications.to_json } end end |
#unsubscribe ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 44 def unsubscribe trackable.unsubscribe # TODO you may want to improve the unsubscribe logic here respond_to do |format| format.json { head :no_content } format.html { redirect_to root_url } end end |
#view ⇒ Object
18 19 20 21 22 23 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 18 def view respond_to do |format| format.html { render text: notification.email_html } format.text { render text: notification.email_text } end end |