From e7a4c47f0a72ae48e7d0d4df122d2b7bbd6b8733 Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Tue, 18 Jan 2011 17:06:54 -0800 Subject: [PATCH] include target for notification --- app/controllers/notifications_controller.rb | 3 +-- app/models/notification.rb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 645cbe6be..f07e8477f 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -18,7 +18,7 @@ class NotificationsController < ApplicationController end def index - @notifications = Notification.for(current_user).paginate :page => params[:page], :per_page => 25 + @notifications = Notification.for(current_user).include(:target).paginate :page => params[:page], :per_page => 25 @group_days = @notifications.group_by{|note| note.created_at.strftime("%B %d") } respond_with @notifications end @@ -27,5 +27,4 @@ class NotificationsController < ApplicationController Notification.where(:recipient_id => current_user.id).update_all(:unread => false) redirect_to :back end - end diff --git a/app/models/notification.rb b/app/models/notification.rb index 113ebbf2f..6f27a589d 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -11,7 +11,7 @@ class Notification < ActiveRecord::Base belongs_to :target, :polymorphic => true def self.for(recipient, opts={}) - self.where(opts.merge!(:recipient_id => recipient.id)).order('created_at desc') + self.where(opts.merge!(:recipient_id => recipient.id)).order('created_at desc').include(:target) end def self.notify(recipient, target, actor)