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
62 63 64 65 66 67 68 69 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 62 def cancel notification.cancel respond_to do |format| format.json { head :no_content } format.html { redirect_to root_url } end end |
#click ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 24 def click notification.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 notification.email_urls.blank? || !notification.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
53 54 55 56 57 58 59 60 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 53 def ignore notification.ignore respond_to do |format| format.json { head :no_content } format.html { redirect_to root_url } end end |
#read ⇒ Object
38 39 40 41 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 38 def read notification.read respond_with_no_content end |
#recent ⇒ Object
11 12 13 14 15 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 11 def recent respond_to do |format| format.json { render json: recent_notifications.to_json } end end |
#unsubscribe ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 43 def unsubscribe notification.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
17 18 19 20 21 22 |
# File 'lib/generators/notifykit/templates/app/controllers/notifications_controller.rb', line 17 def view respond_to do |format| format.html { render text: notification.email_html } format.text { render text: notification.email_text } end end |