diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-10-22 17:37:16 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2014-10-22 17:37:16 +0000 |
commit | 2d1866d966d94c688f9cb87c5bf3f096dffac844 (patch) | |
tree | 7a733c1cc51448ab69b3f892285305dbfb0ae15e /app/models/time_entry.rb | |
parent | a6ec78a4dc658e3517ed682792016b6530458696 (diff) | |
download | redmine-2d1866d966d94c688f9cb87c5bf3f096dffac844.tar.gz redmine-2d1866d966d94c688f9cb87c5bf3f096dffac844.zip |
Merged rails-4.1 branch (#14534).
git-svn-id: http://svn.redmine.org/redmine/trunk@13482 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/time_entry.rb')
-rw-r--r-- | app/models/time_entry.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb index 662070840..8738668cc 100644 --- a/app/models/time_entry.rb +++ b/app/models/time_entry.rb @@ -35,7 +35,7 @@ class TimeEntry < ActiveRecord::Base acts_as_activity_provider :timestamp => "#{table_name}.created_on", :author_key => :user_id, - :find_options => {:include => :project} + :scope => preload(:project) validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on validates_numericality_of :hours, :allow_nil => true, :message => :invalid @@ -45,13 +45,19 @@ class TimeEntry < ActiveRecord::Base validate :validate_time_entry scope :visible, lambda {|*args| - includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_time_entries, *args)) + joins(:project). + references(:project). + where(Project.allowed_to_condition(args.shift || User.current, :view_time_entries, *args)) } scope :on_issue, lambda {|issue| - includes(:issue).where("#{Issue.table_name}.root_id = #{issue.root_id} AND #{Issue.table_name}.lft >= #{issue.lft} AND #{Issue.table_name}.rgt <= #{issue.rgt}") + joins(:issue). + references(:issue). + where("#{Issue.table_name}.root_id = #{issue.root_id} AND #{Issue.table_name}.lft >= #{issue.lft} AND #{Issue.table_name}.rgt <= #{issue.rgt}") } scope :on_project, lambda {|project, include_subprojects| - includes(:project).where(project.project_condition(include_subprojects)) + joins(:project). + references(:project). + where(project.project_condition(include_subprojects)) } scope :spent_between, lambda {|from, to| if from && to |