Permalink
Browse files

add taggings_count to tags and improve tags/manage page

  • Loading branch information...
1 parent bd06424 commit 3cc16e16b2f4bfd739fe07e4439ea7f52dba83a0 @bborn committed Jan 4, 2010
View
@@ -2,9 +2,11 @@
* haml/sass propagation (desert)
* upgrade documentation/rake tasks to fix old migrations
+
= 1.0.4.2
* Rails 2.3.4 compatibility (all tests pass, Takk)
* Add searchlogic gem dependency (searchlogic is awesome, will be using it more in the future, currently just using on admin_controller#comments)
+* Add searchlogic to manage tags page, add taggings_count to tags (new migration)
= 1.0.4
* Changes to Japanese language translations
View
@@ -6,6 +6,13 @@ Run `rake db:migrate`
Run `rake test && rake community_engine:test`
That's it!
+Note: this version adds a counter_cache to taggings, so you may need to update the counter on your existing tags by doing something like:
+
+Tag.all(:limit => 2).each do |tag|
+ Tag.update_counters tag.id, :taggings_count => tag.taggings.length
+end
+
+If you have many tags, this could take a while, though.
Upgrading to v1.0.4
===================
@@ -33,8 +33,8 @@ def users
def comments
@search = Comment.search(params[:search])
-
- @comments = @search.find(:all, :page => {:current => params[:page], :size => 100}, :order => 'created_at DESC')
+ @search.order ||= :descend_by_created_at
+ @comments = @search.find(:all, :page => {:current => params[:page], :size => 100})
end
def activate_user
@@ -24,7 +24,8 @@ def cache_action?
def manage
@search = Post.search(params[:search])
- @posts = @search.find_without_published_as(:all, :conditions => {:user_id => @user.id}, :page => {:current => params[:page], :size => (params[:size] ? params[:size].to_i : 10) }, :order => 'created_at DESC')
+ @search.order ||= :descend_by_created_at
+ @posts = @search.find_without_published_as(:all, :conditions => {:user_id => @user.id}, :page => {:current => params[:page], :size => (params[:size] ? params[:size].to_i : 10) })
end
def index
@@ -9,7 +9,7 @@ def cache_action?
end
def auto_complete_for_tag_name
- @tags = Tag.find(:all, :conditions => [ 'LOWER(name) LIKE ?', '%' + (params[:id] || params[:tag_list]) + '%' ])
+ @tags = Tag.find(:all, :limit => 10, :conditions => [ 'LOWER(name) LIKE ?', '%' + (params[:id] || params[:tag_list]) + '%' ])
render :inline => "<%= auto_complete_result(@tags, 'name') %>"
end
@@ -28,6 +28,13 @@ def index
def manage
@tags = Tag.find(:all, :order => :name, :page => {:current => params[:page], :size => 20})
end
+
+ def manage
+ @search = Tag.search(params[:search])
+ @search.order ||= :ascend_by_name
+ @tags = @search.find(:all, :page => {:current => params[:page], :size => 100})
+ end
+
def edit
@tag = Tag.find_by_name(URI::decode(params[:id]))
@@ -1,17 +1,26 @@
-.yui-b
+.yui-b.sidebar
= render :partial => 'shared/admin_nav'
+
+ -box do
+ %h3=:search.l
+ - form_for @search, :html => {:class => "MainForm"} do |f|
+ = f.label :name.l
+ = f.text_field :name_begins_with
+
+ %p= f.submit :search.l
+
#yui-main
.yui-b
-box do
%h3=:tags.l
%table{:width=>"100%"}
%tr
- %th=:name.l
+ %th
+ =order @search, :by => :name, :as => :name.l
%th
- \#
- =:taggings.l
+ =order @search, :by => :taggings_count, :as => "##{:taggings.l}"
%th=:actions.l
- for tag in @tags
@@ -0,0 +1,9 @@
+class AddTaggingsCountToTags < ActiveRecord::Migration
+ def self.up
+ add_column :tags, :taggings_count, :integer, :default => 0
+ end
+
+ def self.down
+ remove_column :tags, :taggings_count
+ end
+end
@@ -1,5 +1,5 @@
class Tagging < ActiveRecord::Base #:nodoc:
- belongs_to :tag
+ belongs_to :tag, :counter_cache => true
belongs_to :taggable, :polymorphic => true
def after_destroy

0 comments on commit 3cc16e1

Please sign in to comment.