Browse files

Improve PublicActivity compatibility implementation w/ 1.8.

  • Loading branch information...
1 parent dcea95a commit 296205ab4ae707061abcdd7dd52f328334ffce67 @bamnet bamnet committed Mar 25, 2013
Showing with 12 additions and 13 deletions.
  1. +8 −7 app/controllers/feeds_controller.rb
  2. +3 −3 app/views/activities/_show.html.erb
  3. +1 −3 app/views/feeds/index.html.erb
View
15 app/controllers/feeds_controller.rb
@@ -118,20 +118,21 @@ def destroy
private
def get_activities
- if current_user && RUBY_VERSION >= "1.9"
+ @activities = []
+ if current_user && defined? PublicActivity::Activity
#Retrieve the activities for which the current user is an owner or recipient (making sure the STI field specifies user as the Type)
- @owner = PublicActivity::Activity.where(:owner_id => current_user.id, :owner_type => 'User').limit(25)
- @recipient = PublicActivity::Activity.where(:recipient_id => current_user.id, :recipient_type => 'User').limit(25)
+ owner = PublicActivity::Activity.where(:owner_id => current_user.id, :owner_type => 'User').limit(25)
+ recipient = PublicActivity::Activity.where(:recipient_id => current_user.id, :recipient_type => 'User').limit(25)
#Select the activities that involve a group as the recipient for which the user is a member
- @group_member = PublicActivity::Activity.where(:recipient_id => current_user.group_ids, :recipient_type => "Group").limit(10)
+ group_member = PublicActivity::Activity.where(:recipient_id => current_user.group_ids, :recipient_type => "Group").limit(10)
#Select activities with neither an owner nor a recipient (public activities) - the actual owner is set in the parameters hash for these
- @public_activities = PublicActivity::Activity.where(:owner_id => nil, :recipient_id => nil).limit(10)
+ public_activities = PublicActivity::Activity.where(:owner_id => nil, :recipient_id => nil).limit(10)
- @activities = @owner + @recipient + @group_member + @public_activities
+ @activities = owner + recipient + group_member + public_activities
@activities.sort! { |a,b| b.created_at <=> a.created_at }
- end
+ end
end
def feed_params
View
6 app/views/activities/_show.html.erb
@@ -1,10 +1,10 @@
-<p>Recent Activity</p>
-<% if current_user %>
+<% if !@activities.empty? %>
+ <p>Recent Activity</p>
<ul>
<% @activities.each do |activity| %>
<div class="activity">
<li><%= render_activity activity if File.exists?(Rails.root.join("app", "views", "public_activity", activity.key.split('.')[0], "_#{activity.key.split('.')[1]}.html.erb")) %></li>
</div>
<% end %>
</ul>
-<% end %>
+<% end %>
View
4 app/views/feeds/index.html.erb
@@ -24,9 +24,7 @@
<li><%= link_to group.name, group %></li>
<% end %>
</ul>
- <% if RUBY_VERSION >= "1.9" %>
- <%= render :partial => 'activities/show' %>
- <% end %>
+ <%= render :partial => 'activities/show' %>
</div>
</div>

0 comments on commit 296205a

Please sign in to comment.