]> source.dussan.org Git - redmine.git/commitdiff
model: convert news finder to Rails3 syntax
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 4 May 2012 23:35:29 +0000 (23:35 +0000)
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>
Fri, 4 May 2012 23:35:29 +0000 (23:35 +0000)
Contributed by Felix Schäfer.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9624 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/news.rb

index bf1cc4f80fe7b471d944a8af1f36f15736562aec..11be6d130a4a6adaa1cb2d3d6b0d679bfa5e57c4 100644 (file)
@@ -52,10 +52,9 @@ class News < ActiveRecord::Base
 
   # returns latest news for projects visible by user
   def self.latest(user = User.current, count = 5)
-    find(:all, :limit => count,
-         :conditions => Project.allowed_to_condition(user, :view_news),
-         :include => [ :author, :project ],
-         :order => "#{News.table_name}.created_on DESC")       
+    includes([:author, :project]).where(
+        Project.allowed_to_condition(user, :view_news)
+      ).order("#{News.table_name}.created_on DESC").limit(count).all
   end
 
   private