From 7dd37c50d30da7fbd783b2500bc6b8166056445e Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Wed, 16 Nov 2016 23:04:30 -0500 Subject: [PATCH] notifications index/show --- app/controllers/notifications_controller.rb | 19 +++++++++++++++++++ app/models/user.rb | 4 ++++ app/views/notifications/index.html.erb | 18 ++++++++++++++++++ app/views/notifications/show.html.erb | 12 ++++++++++++ 4 files changed, 53 insertions(+) create mode 100644 app/controllers/notifications_controller.rb create mode 100644 app/views/notifications/index.html.erb create mode 100644 app/views/notifications/show.html.erb diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb new file mode 100644 index 00000000..49d9e32c --- /dev/null +++ b/app/controllers/notifications_controller.rb @@ -0,0 +1,19 @@ +class NotificationsController < ApplicationController + def index + @notifications = current_user.mailbox.notifications + + respond_to do |format| + format.html + format.json { render json: @notifications.to_json } + end + end + + def show + @notification = current_user.mailbox.notifications.find_by(id: params[:id]) + + respond_to do |format| + format.html + format.json { render json: @notification.to_json } + end + end +end diff --git a/app/models/user.rb b/app/models/user.rb index 22072edc..e70114d5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -110,4 +110,8 @@ class User < ApplicationRecord def settings=(val) self[:settings] = val end + + def mailboxer_email(object) + nil # email + end end diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb new file mode 100644 index 00000000..9efae3d6 --- /dev/null +++ b/app/views/notifications/index.html.erb @@ -0,0 +1,18 @@ +<% content_for :title, 'Notifications | Metamaps' %> +<% content_for :mobile_title, 'Notifications' %> + +
+
+

Notifications

+
    + <% @notifications.each do |notification| %> +
  • + + <%= link_to notification.subject, notification_path(notification.id) %> + + <%= notification.body.truncate(140) %> +
  • + <% end %> +
+
+
diff --git a/app/views/notifications/show.html.erb b/app/views/notifications/show.html.erb new file mode 100644 index 00000000..14aedd75 --- /dev/null +++ b/app/views/notifications/show.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, 'Notifications | Metamaps' %> +<% content_for :mobile_title, 'Notifications' %> + +
+
+

<%= @notification.subject %>

+
+ <%= @notification.body %> +
+ <%= link_to 'Back', notifications_path %> +
+