Skip to content

Commit

Permalink
Added dummy deleted user to be used when a message associated with a …
Browse files Browse the repository at this point in the history
…user that has been deleted is shown
  • Loading branch information
gabceb committed Feb 14, 2013
1 parent 1e6a668 commit 35e30a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/channels_controller.rb
Expand Up @@ -12,7 +12,7 @@ def index
more_activities = (channel.activities.count > Kandan::Config.options[:per_page])
channel.activities.order('id DESC').includes(:user).page.each do |activity|
activities.push activity.attributes.merge({
:user => activity.user.as_json(:only => [:id, :ido_id, :email, :first_name, :last_name, :gravatar_hash, :active, :locale])
:user => activity.user_or_deleted_user.as_json(:only => [:id, :ido_id, :email, :first_name, :last_name, :gravatar_hash, :active, :locale, :username])
})
end

Expand Down
4 changes: 4 additions & 0 deletions app/models/activity.rb
Expand Up @@ -3,4 +3,8 @@ class Activity < ActiveRecord::Base
belongs_to :channel

paginates_per Kandan::Config.options[:per_page]

def user_or_deleted_user
self.user || User.deleted_user
end
end
7 changes: 7 additions & 0 deletions app/models/user.rb
Expand Up @@ -26,4 +26,11 @@ def active_for_authentication?
super && active?
end

def self.deleted_user
dummy_user = new(:username => "Deleted User", :gravatar_hash => "", :email => "")
dummy_user.active = false

return dummy_user
end

end

0 comments on commit 35e30a3

Please sign in to comment.