Created
November 21, 2011 07:26
-
-
Save pinglamb/1381922 to your computer and use it in GitHub Desktop.
Show sum of collections and hits count in RailsAdmin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/app/models/photo.rb b/app/models/photo.rb | |
index 3c44e48..3fc12cc 100644 | |
--- a/app/models/photo.rb | |
+++ b/app/models/photo.rb | |
@@ -190,4 +190,8 @@ class Photo < ActiveRecord::Base | |
def hide | |
update_attribute(:hidden, true) | |
end | |
+ | |
+ def sum_of_collections_count_and_hits_count | |
+ collections.count + hits.count | |
+ end | |
end | |
diff --git a/config/initializers/rails_admin.rb b/config/initializers/rails_admin.rb | |
index 732dbf6..0f3b03d 100644 | |
--- a/config/initializers/rails_admin.rb | |
+++ b/config/initializers/rails_admin.rb | |
@@ -80,6 +80,7 @@ RailsAdmin.config do |config| | |
field :score do | |
column_width 8 | |
end | |
+ field :sum_of_collections_count_and_hits_count | |
field :weibo_source | |
end | |
show do |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment