Index: app/models/attachment.rb =================================================================== diff --git a/trunk/app/models/attachment.rb b/trunk/app/models/attachment.rb --- a/trunk/app/models/attachment.rb (revision 19833) +++ b/trunk/app/models/attachment.rb (working copy) @@ -38,16 +38,16 @@ acts_as_activity_provider :type => 'files', :permission => :view_files, :author_key => :author_id, - :scope => select("#{Attachment.table_name}.*"). + :scope => proc { select("#{Attachment.table_name}.*"). joins("LEFT JOIN #{Version.table_name} ON #{Attachment.table_name}.container_type='Version' AND #{Version.table_name}.id = #{Attachment.table_name}.container_id " + - "LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )") + "LEFT JOIN #{Project.table_name} ON #{Version.table_name}.project_id = #{Project.table_name}.id OR ( #{Attachment.table_name}.container_type='Project' AND #{Attachment.table_name}.container_id = #{Project.table_name}.id )") } acts_as_activity_provider :type => 'documents', :permission => :view_documents, :author_key => :author_id, - :scope => select("#{Attachment.table_name}.*"). + :scope => proc { select("#{Attachment.table_name}.*"). joins("LEFT JOIN #{Document.table_name} ON #{Attachment.table_name}.container_type='Document' AND #{Document.table_name}.id = #{Attachment.table_name}.container_id " + - "LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id") + "LEFT JOIN #{Project.table_name} ON #{Document.table_name}.project_id = #{Project.table_name}.id") } cattr_accessor :storage_path @@storage_path = Redmine::Configuration['attachments_storage_path'] || File.join(Rails.root, "files") Index: app/models/changeset.rb =================================================================== diff --git a/trunk/app/models/changeset.rb b/trunk/app/models/changeset.rb --- a/trunk/app/models/changeset.rb (revision 19833) +++ b/trunk/app/models/changeset.rb (working copy) @@ -43,7 +43,7 @@ acts_as_activity_provider :timestamp => "#{table_name}.committed_on", :author_key => :user_id, - :scope => preload(:user, {:repository => :project}) + :scope => proc { preload(:user, {:repository => :project}) } validates_presence_of :repository_id, :revision, :committed_on, :commit_date validates_uniqueness_of :revision, :scope => :repository_id Index: app/models/document.rb =================================================================== diff --git a/trunk/app/models/document.rb b/trunk/app/models/document.rb --- a/trunk/app/models/document.rb (revision 19833) +++ b/trunk/app/models/document.rb (working copy) @@ -29,7 +29,7 @@ acts_as_event :title => Proc.new {|o| "#{l(:label_document)}: #{o.title}"}, :author => Proc.new {|o| o.attachments.reorder("#{Attachment.table_name}.created_on ASC").first.try(:author) }, :url => Proc.new {|o| {:controller => 'documents', :action => 'show', :id => o.id}} - acts_as_activity_provider :scope => preload(:project) + acts_as_activity_provider :scope => proc { preload(:project) } validates_presence_of :project, :title, :category validates_length_of :title, :maximum => 255 Index: app/models/issue.rb =================================================================== diff --git a/trunk/app/models/issue.rb b/trunk/app/models/issue.rb --- a/trunk/app/models/issue.rb (revision 19833) +++ b/trunk/app/models/issue.rb (working copy) @@ -51,7 +51,7 @@ :url => Proc.new {|o| {:controller => 'issues', :action => 'show', :id => o.id}}, :type => Proc.new {|o| 'issue' + (o.closed? ? '-closed' : '') } - acts_as_activity_provider :scope => preload(:project, :author, :tracker, :status), + acts_as_activity_provider :scope => proc { preload(:project, :author, :tracker, :status) }, :author_key => :author_id DONE_RATIO_OPTIONS = %w(issue_field issue_status) Index: app/models/journal.rb =================================================================== diff --git a/trunk/app/models/journal.rb b/trunk/app/models/journal.rb --- a/trunk/app/models/journal.rb (revision 19833) +++ b/trunk/app/models/journal.rb (working copy) @@ -38,10 +38,10 @@ acts_as_activity_provider :type => 'issues', :author_key => :user_id, - :scope => preload({:issue => :project}, :user). + :scope => proc { preload({:issue => :project}, :user). joins("LEFT OUTER JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id"). where("#{Journal.table_name}.journalized_type = 'Issue' AND" + - " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct + " (#{JournalDetail.table_name}.prop_key = 'status_id' OR #{Journal.table_name}.notes <> '')").distinct } before_create :split_private_notes after_create_commit :send_notification Index: app/models/message.rb =================================================================== diff --git a/trunk/app/models/message.rb b/trunk/app/models/message.rb --- a/trunk/app/models/message.rb (revision 19833) +++ b/trunk/app/models/message.rb (working copy) @@ -45,7 +45,7 @@ end) } - acts_as_activity_provider :scope => preload({:board => :project}, :author), + acts_as_activity_provider :scope => proc { preload({:board => :project}, :author) }, :author_key => :author_id acts_as_watchable Index: app/models/news.rb =================================================================== diff --git a/trunk/app/models/news.rb b/trunk/app/models/news.rb --- a/trunk/app/models/news.rb (revision 19833) +++ b/trunk/app/models/news.rb (working copy) @@ -32,7 +32,7 @@ acts_as_searchable :columns => ['title', 'summary', "#{table_name}.description"], :preload => :project acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}} - acts_as_activity_provider :scope => preload(:project, :author), + acts_as_activity_provider :scope => proc { preload(:project, :author) }, :author_key => :author_id acts_as_watchable Index: app/models/time_entry.rb =================================================================== diff --git a/trunk/app/models/time_entry.rb b/trunk/app/models/time_entry.rb --- a/trunk/app/models/time_entry.rb (revision 19833) +++ b/trunk/app/models/time_entry.rb (working copy) @@ -41,7 +41,7 @@ acts_as_activity_provider :timestamp => "#{table_name}.created_on", :author_key => :user_id, - :scope => joins(:project).preload(:project) + :scope => proc { joins(:project).preload(:project) } validates_presence_of :author_id, :user_id, :activity_id, :project_id, :hours, :spent_on validates_presence_of :issue_id, :if => lambda { Setting.timelog_required_fields.include?('issue_id') } Index: app/models/wiki_content_version.rb =================================================================== diff --git a/trunk/app/models/wiki_content_version.rb b/trunk/app/models/wiki_content_version.rb --- a/trunk/app/models/wiki_content_version.rb (revision 19833) +++ b/trunk/app/models/wiki_content_version.rb (working copy) @@ -34,13 +34,13 @@ :timestamp => "#{table_name}.updated_on", :author_key => "#{table_name}.author_id", :permission => :view_wiki_edits, - :scope => select("#{table_name}.updated_on, #{table_name}.comments, " + + :scope => proc { select("#{table_name}.updated_on, #{table_name}.comments, " + "#{table_name}.version, #{WikiPage.table_name}.title, " + "#{table_name}.page_id, #{table_name}.author_id, " + "#{table_name}.id"). joins("LEFT JOIN #{WikiPage.table_name} ON #{WikiPage.table_name}.id = #{table_name}.page_id " + "LEFT JOIN #{Wiki.table_name} ON #{Wiki.table_name}.id = #{WikiPage.table_name}.wiki_id " + - "LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Wiki.table_name}.project_id") + "LEFT JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Wiki.table_name}.project_id") } after_destroy :page_update_after_destroy Index: extra/sample_plugin/app/models/meeting.rb =================================================================== diff --git a/trunk/extra/sample_plugin/app/models/meeting.rb b/trunk/extra/sample_plugin/app/models/meeting.rb --- a/trunk/extra/sample_plugin/app/models/meeting.rb (revision 19833) +++ b/trunk/extra/sample_plugin/app/models/meeting.rb (working copy) @@ -7,6 +7,6 @@ :url => Proc.new {|o| {:controller => 'meetings', :action => 'show', :id => o.id}} acts_as_activity_provider :timestamp => 'scheduled_on', - :scope => includes(:project), + :scope => proc { includes(:project) }, :permission => nil end Index: lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb =================================================================== diff --git a/trunk/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb b/trunk/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb --- a/trunk/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb (revision 19833) +++ b/trunk/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb (working copy) @@ -55,7 +55,14 @@ provider_options = activity_provider_options[event_type] raise "#{self.name} can not provide #{event_type} events." if provider_options.nil? - scope = (provider_options[:scope] || self) + scope = provider_options[:scope] + if !scope + scope = self + elsif scope.respond_to?(:call) + scope = scope.call + else + ActiveSupport::Deprecation.warn "acts_as_activity_provider with implicit :scope option is deprecated. Please pass a scope on the #{self.name} as a proc." + end if from && to scope = scope.where("#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to)