[donrails commit] r400 - Fix to show paginate for articles of category.

0 views
Skip to first unread message

codesite...@google.com

unread,
Apr 5, 2009, 7:40:44 PM4/5/09
to donr...@googlegroups.com
Author: yasuhiro
Date: Sun Apr 5 16:39:25 2009
New Revision: 400

Modified:
trunk/app/controllers/notes_controller.rb

Log:
Fix to show paginate for articles of category.

Modified: trunk/app/controllers/notes_controller.rb
==============================================================================
--- trunk/app/controllers/notes_controller.rb (original)
+++ trunk/app/controllers/notes_controller.rb Sun Apr 5 16:39:25 2009
@@ -437,9 +437,20 @@

if @category and @category.id
ccs = collect_category_ids(@category)
+ ccs_count = ccs.length
+ ccs_i = 0
+ ccs_string = ''
+ ccs.each do |ccs1|
+ ccs_i += 1
+ ccs_string += "dona_cas.category_id=#{ccs1}"
+ ccs_string += "OR" if ccs_i < ccs_count
+ end

@articles =
- Article.paginate_by_sql(['SELECT articles.* FROM articles JOIN
dona_cas ON (dona_cas.article_id=articles.id AND dona_cas.category_id="1")
WHERE articles.hidden IS NULL OR articles.hidden = 0'],
+ Article.paginate_by_sql(["SELECT articles.* FROM articles
+JOIN dona_cas
+ ON (dona_cas.article_id=articles.id AND (#{ccs_string}))
+WHERE articles.hidden IS NULL OR articles.hidden = 0"],
:page => params[:page],
:per_page => 10
)

Reply all
Reply to author
Forward
0 new messages