stabby lambda scopes for rails4
Change-Id: I34f2527471cdb4d8cab5cde426ba959baa26189e Reviewed-on: https://gerrit.instructure.com/37151 Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Brian Palmer <brianp@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com> QA-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
f47272f9a7
commit
1277aaae90
|
@ -43,7 +43,7 @@ class AbstractCourse < ActiveRecord::Base
|
|||
save!
|
||||
end
|
||||
|
||||
scope :active, where("abstract_courses.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("abstract_courses.workflow_state<>'deleted'") }
|
||||
|
||||
include StickySisFields
|
||||
are_sis_sticky :name, :short_name, :enrollment_term_id
|
||||
|
|
|
@ -14,7 +14,7 @@ class AccessToken < ActiveRecord::Base
|
|||
# on the scope defined in the auth process (scope has not
|
||||
# yet been implemented)
|
||||
|
||||
scope :active, lambda { where("expires_at IS NULL OR expires_at>?", Time.zone.now) }
|
||||
scope :active, -> { where("expires_at IS NULL OR expires_at>?", Time.zone.now) }
|
||||
|
||||
TOKEN_SIZE = 64
|
||||
OAUTH2_SCOPE_NAMESPACE = '/auth/'
|
||||
|
|
|
@ -1362,12 +1362,10 @@ class Account < ActiveRecord::Base
|
|||
:closed
|
||||
end
|
||||
|
||||
scope :root_accounts, where(:root_account_id => nil)
|
||||
scope :processing_sis_batch, where("accounts.current_sis_batch_id IS NOT NULL").order(:updated_at)
|
||||
scope :name_like, lambda { |name|
|
||||
where(wildcard('accounts.name', name))
|
||||
}
|
||||
scope :active, where("accounts.workflow_state<>'deleted'")
|
||||
scope :root_accounts, -> { where(:root_account_id => nil) }
|
||||
scope :processing_sis_batch, -> { where("accounts.current_sis_batch_id IS NOT NULL").order(:updated_at) }
|
||||
scope :name_like, lambda { |name| where(wildcard('accounts.name', name)) }
|
||||
scope :active, -> { where("accounts.workflow_state<>'deleted'") }
|
||||
|
||||
def canvas_network_enabled?
|
||||
false
|
||||
|
|
|
@ -35,13 +35,8 @@ class AccountReport < ActiveRecord::Base
|
|||
state :deleted
|
||||
end
|
||||
|
||||
scope :last_complete_of_type, lambda { |type, limit = 1|
|
||||
last_of_type(type, limit).where(:progress => '100')
|
||||
}
|
||||
|
||||
scope :last_of_type, lambda { |type, limit = 1|
|
||||
where(:report_type => type).order("updated_at DESC").limit(limit)
|
||||
}
|
||||
scope :last_complete_of_type, lambda { |type, limit = 1| last_of_type(type, limit).where(:progress => '100') }
|
||||
scope :last_of_type, lambda { |type, limit = 1| where(:report_type => type).order("updated_at DESC").limit(limit) }
|
||||
|
||||
def context
|
||||
self.account
|
||||
|
|
|
@ -227,8 +227,8 @@ class AppointmentGroup < ActiveRecord::Base
|
|||
)
|
||||
COND
|
||||
}
|
||||
scope :current, lambda { where("end_at>=?", Time.zone.now.midnight) }
|
||||
scope :current_or_undated, lambda { where("end_at>=? OR end_at IS NULL", Time.zone.now.midnight) }
|
||||
scope :current, -> { where("end_at>=?", Time.zone.now.midnight) }
|
||||
scope :current_or_undated, -> { where("end_at>=? OR end_at IS NULL", Time.zone.now.midnight) }
|
||||
scope :intersecting, lambda { |start_date, end_date| where("start_at<? AND end_at>?", end_date, start_date) }
|
||||
|
||||
set_policy do
|
||||
|
|
|
@ -263,5 +263,5 @@ class AssessmentQuestion < ActiveRecord::Base
|
|||
dup
|
||||
end
|
||||
|
||||
scope :active, where("assessment_questions.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("assessment_questions.workflow_state<>'deleted'") }
|
||||
end
|
||||
|
|
|
@ -140,5 +140,5 @@ class AssessmentQuestionBank < ActiveRecord::Base
|
|||
quiz_groups.destroy_all
|
||||
end
|
||||
|
||||
scope :active, where("assessment_question_banks.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("assessment_question_banks.workflow_state<>'deleted'") }
|
||||
end
|
||||
|
|
|
@ -37,8 +37,8 @@ class AssetUserAccess < ActiveRecord::Base
|
|||
|
||||
scope :for_context, lambda { |context| where(:context_id => context, :context_type => context.class.to_s) }
|
||||
scope :for_user, lambda { |user| where(:user_id => user) }
|
||||
scope :participations, where(:action_level => 'participate')
|
||||
scope :most_recent, order('updated_at DESC')
|
||||
scope :participations, -> { where(:action_level => 'participate') }
|
||||
scope :most_recent, -> { order('updated_at DESC') }
|
||||
|
||||
def category
|
||||
self.asset_category
|
||||
|
|
|
@ -1502,21 +1502,21 @@ class Assignment < ActiveRecord::Base
|
|||
0.5
|
||||
end
|
||||
|
||||
scope :include_submitted_count, select(
|
||||
scope :include_submitted_count, -> { select(
|
||||
"assignments.*, (SELECT COUNT(*) FROM submissions
|
||||
WHERE assignments.id = submissions.assignment_id
|
||||
AND submissions.submission_type IS NOT NULL) AS submitted_count")
|
||||
AND submissions.submission_type IS NOT NULL) AS submitted_count") }
|
||||
|
||||
scope :include_graded_count, select(
|
||||
scope :include_graded_count, -> { select(
|
||||
"assignments.*, (SELECT COUNT(*) FROM submissions
|
||||
WHERE assignments.id = submissions.assignment_id
|
||||
AND submissions.grade IS NOT NULL) AS graded_count")
|
||||
AND submissions.grade IS NOT NULL) AS graded_count") }
|
||||
|
||||
scope :include_quiz_and_topic, includes(:quiz, :discussion_topic)
|
||||
scope :include_quiz_and_topic, -> { includes(:quiz, :discussion_topic) }
|
||||
|
||||
scope :no_graded_quizzes_or_topics, where("submission_types NOT IN ('online_quiz', 'discussion_topic')")
|
||||
scope :no_graded_quizzes_or_topics, -> { where("submission_types NOT IN ('online_quiz', 'discussion_topic')") }
|
||||
|
||||
scope :with_submissions, includes(:submissions)
|
||||
scope :with_submissions, -> { includes(:submissions) }
|
||||
|
||||
scope :for_context_codes, lambda { |codes| where(:context_code => codes) }
|
||||
scope :for_course, lambda { |course_id| where(:context_type => 'Course', :context_id => course_id) }
|
||||
|
@ -1524,11 +1524,11 @@ class Assignment < ActiveRecord::Base
|
|||
scope :due_before, lambda { |date| where("assignments.due_at<?", date) }
|
||||
|
||||
scope :due_after, lambda { |date| where("assignments.due_at>?", date) }
|
||||
scope :undated, where(:due_at => nil)
|
||||
scope :undated, -> { where(:due_at => nil) }
|
||||
|
||||
scope :only_graded, where("submission_types<>'not_graded'")
|
||||
scope :only_graded, -> { where("submission_types<>'not_graded'") }
|
||||
|
||||
scope :with_just_calendar_attributes, lambda {
|
||||
scope :with_just_calendar_attributes, -> {
|
||||
select(((Assignment.column_names & CalendarEvent.column_names) + ['due_at', 'assignment_group_id', 'could_be_locked', 'unlock_at', 'lock_at', 'submission_types', '(freeze_on_copy AND copied) AS frozen'] - ['cloned_item_id', 'migration_id']).join(", "))
|
||||
}
|
||||
|
||||
|
@ -1560,7 +1560,7 @@ class Assignment < ActiveRecord::Base
|
|||
# query as ambigious for the "due_at" field if combined with another table
|
||||
# (e.g. assignment overrides) with similar fields (like id,lock_at,etc),
|
||||
# throwing an error.
|
||||
scope :api_needed_fields, select(API_NEEDED_FIELDS.map{ |f| "assignments." + f.to_s})
|
||||
scope :api_needed_fields, -> { select(API_NEEDED_FIELDS.map{ |f| "assignments." + f.to_s}) }
|
||||
|
||||
# This should only be used in the course drop down to show assignments needing a submission
|
||||
scope :need_submitting_info, lambda { |user_id, limit|
|
||||
|
@ -1595,22 +1595,22 @@ class Assignment < ActiveRecord::Base
|
|||
end
|
||||
}
|
||||
|
||||
scope :expecting_submission, where("submission_types NOT IN ('', 'none', 'not_graded', 'on_paper') AND submission_types IS NOT NULL")
|
||||
scope :expecting_submission, -> { where("submission_types NOT IN ('', 'none', 'not_graded', 'on_paper') AND submission_types IS NOT NULL") }
|
||||
|
||||
scope :gradeable, where("assignments.submission_types<>'not_graded'")
|
||||
scope :gradeable, -> { where("assignments.submission_types<>'not_graded'") }
|
||||
|
||||
scope :active, where("assignments.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("assignments.workflow_state<>'deleted'") }
|
||||
scope :before, lambda { |date| where("assignments.created_at<?", date) }
|
||||
|
||||
scope :not_locked, lambda {
|
||||
scope :not_locked, -> {
|
||||
where("(assignments.unlock_at IS NULL OR assignments.unlock_at<:now) AND (assignments.lock_at IS NULL OR assignments.lock_at>:now)",
|
||||
:now => Time.zone.now)
|
||||
}
|
||||
|
||||
scope :order_by_base_due_at, order("assignments.due_at")
|
||||
scope :order_by_base_due_at, -> { order("assignments.due_at") }
|
||||
|
||||
scope :unpublished, where(:workflow_state => 'unpublished')
|
||||
scope :published, where(:workflow_state => 'published')
|
||||
scope :unpublished, -> { where(:workflow_state => 'unpublished') }
|
||||
scope :published, -> { where(:workflow_state => 'published') }
|
||||
|
||||
def overdue?
|
||||
due_at && due_at <= Time.now
|
||||
|
|
|
@ -146,8 +146,8 @@ class AssignmentGroup < ActiveRecord::Base
|
|||
self.assignments.map{|a| a.points_possible || 0}.sum
|
||||
end
|
||||
|
||||
scope :include_active_assignments, includes(:active_assignments)
|
||||
scope :active, where("assignment_groups.workflow_state<>'deleted'")
|
||||
scope :include_active_assignments, -> { includes(:active_assignments) }
|
||||
scope :active, -> { where("assignment_groups.workflow_state<>'deleted'") }
|
||||
scope :before, lambda { |date| where("assignment_groups.created_at<?", date) }
|
||||
scope :for_context_codes, lambda { |codes| active.where(:context_code => codes).order(:position) }
|
||||
scope :for_course, lambda { |course| where(:context_id => course, :context_type => 'Course') }
|
||||
|
|
|
@ -107,7 +107,7 @@ class AssignmentOverride < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
scope :active, where(:workflow_state => 'active')
|
||||
scope :active, -> { where(:workflow_state => 'active') }
|
||||
|
||||
before_validation :default_values
|
||||
def default_values
|
||||
|
|
|
@ -1253,11 +1253,11 @@ class Attachment < ActiveRecord::Base
|
|||
state :unattached_temporary
|
||||
end
|
||||
|
||||
scope :visible, where(['attachments.file_state in (?, ?)', 'available', 'public'])
|
||||
scope :not_deleted, where("attachments.file_state<>'deleted'")
|
||||
scope :visible, -> { where(['attachments.file_state in (?, ?)', 'available', 'public']) }
|
||||
scope :not_deleted, -> { where("attachments.file_state<>'deleted'") }
|
||||
|
||||
scope :not_hidden, where("attachments.file_state<>'hidden'")
|
||||
scope :not_locked, lambda {
|
||||
scope :not_hidden, -> { where("attachments.file_state<>'hidden'") }
|
||||
scope :not_locked, -> {
|
||||
where("(attachments.locked IS NULL OR attachments.locked=?) AND ((attachments.lock_at IS NULL) OR
|
||||
(attachments.lock_at>? OR (attachments.unlock_at IS NOT NULL AND attachments.unlock_at<?)))", false, Time.now.utc, Time.now.utc)
|
||||
}
|
||||
|
@ -1631,14 +1631,14 @@ class Attachment < ActiveRecord::Base
|
|||
def self.serialization_methods; [:mime_class, :scribdable?, :currently_locked, :crocodoc_available?]; end
|
||||
cattr_accessor :skip_thumbnails
|
||||
|
||||
scope :scribdable?, where("scribd_mime_type_id IS NOT NULL")
|
||||
scope :recyclable, where("attachments.scribd_attempts<? AND attachments.workflow_state='errored'", MAX_SCRIBD_ATTEMPTS)
|
||||
scope :needing_scribd_conversion_status, lambda { where("attachments.workflow_state='processing' AND attachments.updated_at<? AND scribd_doc IS NOT NULL", 30.minutes.ago).limit(50) }
|
||||
scope :uploadable, where(:workflow_state => 'pending_upload')
|
||||
scope :active, where(:file_state => 'available')
|
||||
scope :thumbnailable?, where(:content_type => Technoweenie::AttachmentFu.content_types)
|
||||
scope :by_display_name, lambda { order(display_name_order_by_clause('attachments')) }
|
||||
scope :by_position_then_display_name, lambda { order("attachments.position, #{display_name_order_by_clause('attachments')}") }
|
||||
scope :scribdable?, -> { where("scribd_mime_type_id IS NOT NULL") }
|
||||
scope :recyclable, -> { where("attachments.scribd_attempts<? AND attachments.workflow_state='errored'", MAX_SCRIBD_ATTEMPTS) }
|
||||
scope :needing_scribd_conversion_status, -> { where("attachments.workflow_state='processing' AND attachments.updated_at<? AND scribd_doc IS NOT NULL", 30.minutes.ago).limit(50) }
|
||||
scope :uploadable, -> { where(:workflow_state => 'pending_upload') }
|
||||
scope :active, -> { where(:file_state => 'available') }
|
||||
scope :thumbnailable?, -> { where(:content_type => Technoweenie::AttachmentFu.content_types) }
|
||||
scope :by_display_name, -> { order(display_name_order_by_clause('attachments')) }
|
||||
scope :by_position_then_display_name, -> { order("attachments.position, #{display_name_order_by_clause('attachments')}") }
|
||||
def self.serialization_excludes; [:uuid, :namespace]; end
|
||||
def set_serialization_options
|
||||
if self.scribd_doc
|
||||
|
|
|
@ -115,11 +115,11 @@ class CalendarEvent < ActiveRecord::Base
|
|||
effective_context_code && ActiveRecord::Base.find_by_asset_string(effective_context_code) || context
|
||||
end
|
||||
|
||||
scope :order_by_start_at, order(:start_at)
|
||||
scope :order_by_start_at, -> { order(:start_at) }
|
||||
|
||||
scope :active, where("calendar_events.workflow_state<>'deleted'")
|
||||
scope :are_locked, where(:workflow_state => 'locked')
|
||||
scope :are_unlocked, where("calendar_events.workflow_state NOT IN ('deleted', 'locked')")
|
||||
scope :active, -> { where("calendar_events.workflow_state<>'deleted'") }
|
||||
scope :are_locked, -> { where(:workflow_state => 'locked') }
|
||||
scope :are_unlocked, -> { where("calendar_events.workflow_state NOT IN ('deleted', 'locked')") }
|
||||
|
||||
# controllers/apis/etc. should generally use for_user_and_context_codes instead
|
||||
scope :for_context_codes, lambda { |codes| where(:context_code => codes) }
|
||||
|
@ -161,10 +161,10 @@ class CalendarEvent < ActiveRecord::Base
|
|||
SQL
|
||||
}
|
||||
|
||||
scope :undated, where(:start_at => nil, :end_at => nil)
|
||||
scope :undated, -> { where(:start_at => nil, :end_at => nil) }
|
||||
|
||||
scope :between, lambda { |start, ending| where(:start_at => start..ending) }
|
||||
scope :current, lambda { where("calendar_events.end_at>=?", Time.zone.now.midnight) }
|
||||
scope :current, -> { where("calendar_events.end_at>=?", Time.zone.now.midnight) }
|
||||
scope :updated_after, lambda { |*args|
|
||||
if args.first
|
||||
where("calendar_events.updated_at IS NULL OR calendar_events.updated_at>?", args.first)
|
||||
|
@ -173,8 +173,8 @@ class CalendarEvent < ActiveRecord::Base
|
|||
end
|
||||
}
|
||||
|
||||
scope :events_without_child_events, where("NOT EXISTS (SELECT 1 FROM calendar_events children WHERE children.parent_calendar_event_id = calendar_events.id AND children.workflow_state<>'deleted')")
|
||||
scope :events_with_child_events, where("EXISTS (SELECT 1 FROM calendar_events children WHERE children.parent_calendar_event_id = calendar_events.id AND children.workflow_state<>'deleted')")
|
||||
scope :events_without_child_events, -> { where("NOT EXISTS (SELECT 1 FROM calendar_events children WHERE children.parent_calendar_event_id = calendar_events.id AND children.workflow_state<>'deleted')") }
|
||||
scope :events_with_child_events, -> { where("EXISTS (SELECT 1 FROM calendar_events children WHERE children.parent_calendar_event_id = calendar_events.id AND children.workflow_state<>'deleted')") }
|
||||
|
||||
def validate_context!
|
||||
@validate_context = true
|
||||
|
|
|
@ -88,7 +88,7 @@ class Collaboration < ActiveRecord::Base
|
|||
can :read and can :update and can :delete
|
||||
end
|
||||
|
||||
scope :active, where("collaborations.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("collaborations.workflow_state<>'deleted'") }
|
||||
|
||||
scope :after, lambda { |date| where("collaborations.updated_at>?", date) }
|
||||
|
||||
|
|
|
@ -235,11 +235,11 @@ class CommunicationChannel < ActiveRecord::Base
|
|||
where("#{by_path_condition("communication_channels.path")}=#{by_path_condition("?")}", path)
|
||||
}
|
||||
|
||||
scope :email, where(:path_type => TYPE_EMAIL)
|
||||
scope :sms, where(:path_type => TYPE_SMS)
|
||||
scope :email, -> { where(:path_type => TYPE_EMAIL) }
|
||||
scope :sms, -> { where(:path_type => TYPE_SMS) }
|
||||
|
||||
scope :active, where(:workflow_state => 'active')
|
||||
scope :unretired, where("communication_channels.workflow_state<>'retired'")
|
||||
scope :active, -> { where(:workflow_state => 'active') }
|
||||
scope :unretired, -> { where("communication_channels.workflow_state<>'retired'") }
|
||||
|
||||
scope :for_notification_frequency, lambda { |notification, frequency|
|
||||
includes(:notification_policies).where(:notification_policies => { :notification_id => notification, :frequency => frequency })
|
||||
|
@ -262,10 +262,10 @@ class CommunicationChannel < ActiveRecord::Base
|
|||
all
|
||||
end
|
||||
|
||||
scope :include_policies, includes(:notification_policies)
|
||||
scope :include_policies, -> { includes(:notification_policies) }
|
||||
|
||||
scope :in_state, lambda { |state| where(:workflow_state => state.to_s) }
|
||||
scope :of_type, lambda {|type| where(:path_type => type) }
|
||||
scope :of_type, lambda { |type| where(:path_type => type) }
|
||||
|
||||
def can_notify?
|
||||
self.notification_policies.any? { |np| np.frequency == 'never' } ? false : true
|
||||
|
|
|
@ -210,12 +210,12 @@ class ContentExport < ActiveRecord::Base
|
|||
self.job_progress.try(:update_completion!, val)
|
||||
end
|
||||
|
||||
scope :active, where("workflow_state<>'deleted'")
|
||||
scope :not_for_copy, where("export_type<>?", COURSE_COPY)
|
||||
scope :common_cartridge, where(:export_type => COMMON_CARTRIDGE)
|
||||
scope :qti, where(:export_type => QTI)
|
||||
scope :course_copy, where(:export_type => COURSE_COPY)
|
||||
scope :running, where(:workflow_state => ['created', 'exporting'])
|
||||
scope :active, -> { where("workflow_state<>'deleted'") }
|
||||
scope :not_for_copy, -> { where("export_type<>?", COURSE_COPY) }
|
||||
scope :common_cartridge, -> { where(:export_type => COMMON_CARTRIDGE) }
|
||||
scope :qti, -> { where(:export_type => QTI) }
|
||||
scope :course_copy, -> { where(:export_type => COURSE_COPY) }
|
||||
scope :running, -> { where(:workflow_state => ['created', 'exporting']) }
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -465,10 +465,10 @@ class ContentMigration < ActiveRecord::Base
|
|||
|
||||
scope :for_context, lambda { |context| where(:context_id => context, :context_type => context.class.to_s) }
|
||||
|
||||
scope :successful, where(:workflow_state => 'imported')
|
||||
scope :running, where(:workflow_state => ['exporting', 'importing'])
|
||||
scope :waiting, where(:workflow_state => 'exported')
|
||||
scope :failed, where(:workflow_state => ['failed', 'pre_process_error'])
|
||||
scope :successful, -> { where(:workflow_state => 'imported') }
|
||||
scope :running, -> { where(:workflow_state => ['exporting', 'importing']) }
|
||||
scope :waiting, -> { where(:workflow_state => 'exported') }
|
||||
scope :failed, -> { where(:workflow_state => ['failed', 'pre_process_error']) }
|
||||
|
||||
def complete?
|
||||
%w[imported failed pre_process_error].include?(workflow_state)
|
||||
|
|
|
@ -84,8 +84,8 @@ class ContentTag < ActiveRecord::Base
|
|||
|
||||
alias_method :published?, :active?
|
||||
|
||||
scope :active, where(:workflow_state => 'active')
|
||||
scope :not_deleted, where("content_tags.workflow_state<>'deleted'")
|
||||
scope :active, -> { where(:workflow_state => 'active') }
|
||||
scope :not_deleted, -> { where("content_tags.workflow_state<>'deleted'") }
|
||||
|
||||
attr_accessor :skip_touch
|
||||
def touch_context_module
|
||||
|
@ -414,8 +414,8 @@ class ContentTag < ActiveRecord::Base
|
|||
where(:context_type => context.class.to_s, :context_id => context)
|
||||
end
|
||||
}
|
||||
scope :learning_outcome_alignments, where(:tag_type => 'learning_outcome')
|
||||
scope :learning_outcome_links, where(:tag_type => 'learning_outcome_association', :associated_asset_type => 'LearningOutcomeGroup', :content_type => 'LearningOutcome')
|
||||
scope :learning_outcome_alignments, -> { where(:tag_type => 'learning_outcome') }
|
||||
scope :learning_outcome_links, -> { where(:tag_type => 'learning_outcome_association', :associated_asset_type => 'LearningOutcomeGroup', :content_type => 'LearningOutcome') }
|
||||
|
||||
# only intended for learning outcome links
|
||||
def self.outcome_title_order_by_clause
|
||||
|
|
|
@ -547,7 +547,7 @@ class ContextExternalTool < ActiveRecord::Base
|
|||
|
||||
tool
|
||||
end
|
||||
scope :active, where("context_external_tools.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("context_external_tools.workflow_state<>'deleted'") }
|
||||
|
||||
def self.find_all_for(context, type)
|
||||
tools = []
|
||||
|
|
|
@ -140,9 +140,9 @@ class ContextModule < ActiveRecord::Base
|
|||
state :deleted
|
||||
end
|
||||
|
||||
scope :active, where(:workflow_state => 'active')
|
||||
scope :unpublished, where(:workflow_state => 'unpublished')
|
||||
scope :not_deleted, where("context_modules.workflow_state<>'deleted'")
|
||||
scope :active, -> { where(:workflow_state => 'active') }
|
||||
scope :unpublished, -> { where(:workflow_state => 'unpublished') }
|
||||
scope :not_deleted, -> { where("context_modules.workflow_state<>'deleted'") }
|
||||
|
||||
alias_method :published?, :active?
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class ConversationBatch < ActiveRecord::Base
|
|||
|
||||
validates_presence_of :user_id, :workflow_state, :root_conversation_message_id
|
||||
|
||||
scope :in_progress, where(:workflow_state => ['created', 'sending'])
|
||||
scope :in_progress, -> { where(:workflow_state => ['created', 'sending']) }
|
||||
|
||||
attr_accessible
|
||||
attr_accessor :mode
|
||||
|
|
|
@ -51,9 +51,9 @@ class ConversationMessage < ActiveRecord::Base
|
|||
|
||||
after_create :generate_user_note!
|
||||
|
||||
scope :human, where("NOT generated")
|
||||
scope :with_attachments, where("attachment_ids<>'' OR has_attachments") # TODO: simplify post-migration
|
||||
scope :with_media_comments, where("media_comment_id IS NOT NULL OR has_media_objects") # TODO: simplify post-migration
|
||||
scope :human, -> { where("NOT generated") }
|
||||
scope :with_attachments, -> { where("attachment_ids<>'' OR has_attachments") } # TODO: simplify post-migration
|
||||
scope :with_media_comments, -> { where("media_comment_id IS NOT NULL OR has_media_objects") } # TODO: simplify post-migration
|
||||
scope :by_user, lambda { |user_or_id| where(:author_id => user_or_id) }
|
||||
|
||||
def self.preload_latest(conversation_participants, author=nil)
|
||||
|
|
|
@ -31,8 +31,8 @@ class ConversationMessageParticipant < ActiveRecord::Base
|
|||
EXPORTABLE_ATTRIBUTES = [:id, :conversation_message_id, :conversation_participant_id, :tags, :user_id, :workflow_state]
|
||||
EXPORTABLE_ASSOCIATIONS = [:conversation_message, :user, :conversation_participant]
|
||||
|
||||
scope :active, where("(conversation_message_participants.workflow_state <> 'deleted' OR conversation_message_participants.workflow_state IS NULL)")
|
||||
scope :deleted, where("conversation_message_participants.workflow_state = 'deleted'")
|
||||
scope :active, -> { where("(conversation_message_participants.workflow_state <> 'deleted' OR conversation_message_participants.workflow_state IS NULL)") }
|
||||
scope :deleted, -> { where(workflow_state: 'deleted') }
|
||||
|
||||
scope :for_conversation_and_message, lambda { |conversation_id, message_id|
|
||||
joins("INNER JOIN conversation_participants ON conversation_participants.id = conversation_participant_id").
|
||||
|
|
|
@ -36,12 +36,12 @@ class ConversationParticipant < ActiveRecord::Base
|
|||
|
||||
after_destroy :destroy_conversation_message_participants
|
||||
|
||||
scope :visible, where("last_message_at IS NOT NULL")
|
||||
scope :default, where(:workflow_state => ['read', 'unread'])
|
||||
scope :unread, where(:workflow_state => 'unread')
|
||||
scope :archived, where(:workflow_state => 'archived')
|
||||
scope :starred, where(:label => 'starred')
|
||||
scope :sent, where("visible_last_authored_at IS NOT NULL").order("visible_last_authored_at DESC, conversation_id DESC")
|
||||
scope :visible, -> { where("last_message_at IS NOT NULL") }
|
||||
scope :default, -> { where(:workflow_state => ['read', 'unread']) }
|
||||
scope :unread, -> { where(:workflow_state => 'unread') }
|
||||
scope :archived, -> { where(:workflow_state => 'archived') }
|
||||
scope :starred, -> { where(:label => 'starred') }
|
||||
scope :sent, -> { where("visible_last_authored_at IS NOT NULL").order("visible_last_authored_at DESC, conversation_id DESC") }
|
||||
scope :for_masquerading_user, lambda { |user|
|
||||
# site admins can see everything
|
||||
return scoped if user.account_users.map(&:account_id).include?(Account.site_admin.id)
|
||||
|
|
|
@ -490,14 +490,14 @@ class Course < ActiveRecord::Base
|
|||
accounts
|
||||
end
|
||||
|
||||
scope :recently_started, lambda { where(:start_at => 1.month.ago..Time.zone.now).order("start_at DESC").limit(10) }
|
||||
scope :recently_ended, lambda { where(:conclude_at => 1.month.ago..Time.zone.now).order("start_at DESC").limit(10) }
|
||||
scope :recently_created, lambda { where("created_at>?", 1.month.ago).order("created_at DESC").limit(50).includes(:teachers) }
|
||||
scope :recently_started, -> { where(:start_at => 1.month.ago..Time.zone.now).order("start_at DESC").limit(10) }
|
||||
scope :recently_ended, -> { where(:conclude_at => 1.month.ago..Time.zone.now).order("start_at DESC").limit(10) }
|
||||
scope :recently_created, -> { where("created_at>?", 1.month.ago).order("created_at DESC").limit(50).includes(:teachers) }
|
||||
scope :for_term, lambda {|term| term ? where(:enrollment_term_id => term) : scoped }
|
||||
scope :active_first, lambda { order("CASE WHEN courses.workflow_state='available' THEN 0 ELSE 1 END, #{best_unicode_collation_key('name')}") }
|
||||
scope :active_first, -> { order("CASE WHEN courses.workflow_state='available' THEN 0 ELSE 1 END, #{best_unicode_collation_key('name')}") }
|
||||
scope :name_like, lambda { |name| where(wildcard('courses.name', 'courses.sis_source_id', 'courses.course_code', name)) }
|
||||
scope :needs_account, lambda { |account, limit| where(:account_id => nil, :root_account_id => account).limit(limit) }
|
||||
scope :active, where("courses.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("courses.workflow_state<>'deleted'") }
|
||||
scope :least_recently_updated, lambda { |limit| order(:updated_at).limit(limit) }
|
||||
scope :manageable_by_user, lambda { |*args|
|
||||
# args[0] should be user_id, args[1], if true, will include completed
|
||||
|
@ -514,19 +514,19 @@ class Course < ActiveRecord::Base
|
|||
WHERE courses.workflow_state <> 'deleted') as course_users
|
||||
ON course_users.course_id = courses.id")
|
||||
}
|
||||
scope :not_deleted, where("workflow_state<>'deleted'")
|
||||
scope :not_deleted, -> { where("workflow_state<>'deleted'") }
|
||||
|
||||
scope :with_enrollments, lambda {
|
||||
scope :with_enrollments, -> {
|
||||
where("EXISTS (?)", Enrollment.active.where("enrollments.course_id=courses.id"))
|
||||
}
|
||||
scope :without_enrollments, lambda {
|
||||
scope :without_enrollments, -> {
|
||||
where("NOT EXISTS (?)", Enrollment.active.where("enrollments.course_id=courses.id"))
|
||||
}
|
||||
scope :completed, lambda {
|
||||
scope :completed, -> {
|
||||
joins(:enrollment_term).
|
||||
where("courses.workflow_state='completed' OR courses.conclude_at<? OR enrollment_terms.end_at<?", Time.now.utc, Time.now.utc)
|
||||
}
|
||||
scope :not_completed, lambda {
|
||||
scope :not_completed, -> {
|
||||
joins(:enrollment_term).
|
||||
where("courses.workflow_state<>'completed' AND
|
||||
(courses.conclude_at IS NULL OR courses.conclude_at>=?) AND
|
||||
|
@ -537,13 +537,13 @@ class Course < ActiveRecord::Base
|
|||
none :
|
||||
where("EXISTS (?)", Enrollment.active.where("enrollments.course_id=courses.id AND enrollments.type='TeacherEnrollment' AND enrollments.user_id IN (?)", teacher_ids))
|
||||
}
|
||||
scope :by_associated_accounts, lambda{ |account_ids|
|
||||
scope :by_associated_accounts, lambda { |account_ids|
|
||||
account_ids.empty? ?
|
||||
none :
|
||||
where("EXISTS (?)", CourseAccountAssociation.where("course_account_associations.course_id=courses.id AND course_account_associations.account_id IN (?)", account_ids))
|
||||
}
|
||||
|
||||
scope :deleted, where(:workflow_state => 'deleted')
|
||||
scope :deleted, -> { where(:workflow_state => 'deleted') }
|
||||
|
||||
set_broadcast_policy do |p|
|
||||
p.dispatch :grade_weight_changed
|
||||
|
|
|
@ -246,7 +246,7 @@ class CourseSection < ActiveRecord::Base
|
|||
save!
|
||||
end
|
||||
|
||||
scope :active, where("course_sections.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("course_sections.workflow_state<>'deleted'") }
|
||||
|
||||
scope :sis_sections, lambda { |account, *source_ids| where(:root_account_id => account, :sis_source_id => source_ids).order(:sis_source_id) }
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ class CustomGradebookColumn < ActiveRecord::Base
|
|||
state :deleted
|
||||
end
|
||||
|
||||
scope :active, where(workflow_state: "active")
|
||||
scope :not_deleted, where("workflow_state != 'deleted'")
|
||||
scope :active, -> { where(workflow_state: "active") }
|
||||
scope :not_deleted, -> { where("workflow_state != 'deleted'") }
|
||||
|
||||
set_policy do
|
||||
given { |user, session|
|
||||
|
|
|
@ -74,11 +74,11 @@ class DelayedMessage < ActiveRecord::Base
|
|||
|
||||
scope :in_state, lambda { |state| where(:workflow_state => state.to_s) }
|
||||
|
||||
scope :to_summarize, lambda {
|
||||
scope :to_summarize, -> {
|
||||
where("delayed_messages.workflow_state='pending' and delayed_messages.send_at<=?", Time.now.utc)
|
||||
}
|
||||
|
||||
scope :next_to_summarize, lambda {
|
||||
scope :next_to_summarize, -> {
|
||||
where(:workflow_state => 'pending').order(:send_at).limit(1)
|
||||
}
|
||||
|
||||
|
|
|
@ -238,8 +238,8 @@ class DiscussionEntry < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
scope :active, where("discussion_entries.workflow_state<>'deleted'")
|
||||
scope :deleted, where(:workflow_state => 'deleted')
|
||||
scope :active, -> { where("discussion_entries.workflow_state<>'deleted'") }
|
||||
scope :deleted, -> { where(:workflow_state => 'deleted') }
|
||||
|
||||
def user_name
|
||||
self.user.name rescue t :default_user_name, "User Name"
|
||||
|
@ -308,9 +308,9 @@ class DiscussionEntry < ActiveRecord::Base
|
|||
scope :for_user, lambda { |user| where(:user_id => user).order("discussion_entries.created_at") }
|
||||
scope :for_users, lambda { |users| where(:user_id => users) }
|
||||
scope :after, lambda { |date| where("created_at>?", date) }
|
||||
scope :top_level_for_topics, lambda {|topics| where(:root_entry_id => nil, :discussion_topic_id => topics) }
|
||||
scope :top_level_for_topics, lambda { |topics| where(:root_entry_id => nil, :discussion_topic_id => topics) }
|
||||
scope :all_for_topics, lambda { |topics| where(:discussion_topic_id => topics) }
|
||||
scope :newest_first, order("discussion_entries.created_at DESC, discussion_entries.id DESC")
|
||||
scope :newest_first, -> { order("discussion_entries.created_at DESC, discussion_entries.id DESC") }
|
||||
|
||||
def to_atom(opts={})
|
||||
author_name = self.user.present? ? self.user.name : t('atom_no_author', "No Author")
|
||||
|
|
|
@ -45,7 +45,7 @@ class DiscussionEntryParticipant < ActiveRecord::Base
|
|||
state :read
|
||||
end
|
||||
|
||||
scope :read, where(:workflow_state => 'read')
|
||||
scope :read, -> { where(:workflow_state => 'read') }
|
||||
scope :existing_participants, ->(user, entry_id) {
|
||||
select([:id, :discussion_entry_id]).
|
||||
where(user_id: user, discussion_entry_id: entry_id)
|
||||
|
|
|
@ -462,17 +462,17 @@ class DiscussionTopic < ActiveRecord::Base
|
|||
topic_participant
|
||||
end
|
||||
|
||||
scope :recent, lambda { where("discussion_topics.last_reply_at>?", 2.weeks.ago).order("discussion_topics.last_reply_at DESC") }
|
||||
scope :only_discussion_topics, where(:type => nil)
|
||||
scope :for_subtopic_refreshing, where("discussion_topics.subtopics_refreshed_at IS NOT NULL AND discussion_topics.subtopics_refreshed_at<discussion_topics.updated_at").order("discussion_topics.subtopics_refreshed_at")
|
||||
scope :active, where("discussion_topics.workflow_state<>'deleted'")
|
||||
scope :for_context_codes, lambda {|codes| where(:context_code => codes) }
|
||||
scope :recent, -> { where("discussion_topics.last_reply_at>?", 2.weeks.ago).order("discussion_topics.last_reply_at DESC") }
|
||||
scope :only_discussion_topics, -> { where(:type => nil) }
|
||||
scope :for_subtopic_refreshing, -> { where("discussion_topics.subtopics_refreshed_at IS NOT NULL AND discussion_topics.subtopics_refreshed_at<discussion_topics.updated_at").order("discussion_topics.subtopics_refreshed_at") }
|
||||
scope :active, -> { where("discussion_topics.workflow_state<>'deleted'") }
|
||||
scope :for_context_codes, lambda { |codes| where(:context_code => codes) }
|
||||
|
||||
scope :before, lambda { |date| where("discussion_topics.created_at<?", date) }
|
||||
|
||||
scope :by_position, order("discussion_topics.position ASC, discussion_topics.created_at DESC, discussion_topics.id DESC")
|
||||
scope :by_position_legacy, order("discussion_topics.position DESC, discussion_topics.created_at DESC, discussion_topics.id DESC")
|
||||
scope :by_last_reply_at, order("discussion_topics.last_reply_at DESC, discussion_topics.created_at DESC, discussion_topics.id DESC")
|
||||
scope :by_position, -> { order("discussion_topics.position ASC, discussion_topics.created_at DESC, discussion_topics.id DESC") }
|
||||
scope :by_position_legacy, -> { order("discussion_topics.position DESC, discussion_topics.created_at DESC, discussion_topics.id DESC") }
|
||||
scope :by_last_reply_at, -> { order("discussion_topics.last_reply_at DESC, discussion_topics.created_at DESC, discussion_topics.id DESC") }
|
||||
|
||||
alias_attribute :available_from, :delayed_post_at
|
||||
alias_attribute :unlock_at, :delayed_post_at
|
||||
|
|
|
@ -148,40 +148,40 @@ class Enrollment < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
|
||||
scope :active, where("enrollments.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("enrollments.workflow_state<>'deleted'") }
|
||||
|
||||
scope :admin,
|
||||
select(:course_id).
|
||||
scope :admin, -> {
|
||||
select(:course_id).
|
||||
joins(:course).
|
||||
where("enrollments.type IN ('TeacherEnrollment','TaEnrollment', 'DesignerEnrollment')
|
||||
AND (courses.workflow_state='claimed' OR (enrollments.workflow_state='active' AND courses.workflow_state='available'))")
|
||||
AND (courses.workflow_state='claimed' OR (enrollments.workflow_state='active' AND courses.workflow_state='available'))") }
|
||||
|
||||
scope :of_admin_type, where(:type => ['TeacherEnrollment','TaEnrollment', 'DesignerEnrollment'])
|
||||
scope :of_admin_type, -> { where(:type => ['TeacherEnrollment','TaEnrollment', 'DesignerEnrollment']) }
|
||||
|
||||
scope :of_instructor_type, where(:type => ['TeacherEnrollment', 'TaEnrollment'])
|
||||
scope :of_instructor_type, -> { where(:type => ['TeacherEnrollment', 'TaEnrollment']) }
|
||||
|
||||
scope :of_content_admins, where(:type => ['TeacherEnrollment', 'DesignerEnrollment'])
|
||||
scope :of_content_admins, -> { where(:type => ['TeacherEnrollment', 'DesignerEnrollment']) }
|
||||
|
||||
scope :student,
|
||||
select(:course_id).
|
||||
scope :student, -> {
|
||||
select(:course_id).
|
||||
joins(:course).
|
||||
where(:type => 'StudentEnrollment', :workflow_state => 'active', :courses => { :workflow_state => 'available' })
|
||||
where(:type => 'StudentEnrollment', :workflow_state => 'active', :courses => { :workflow_state => 'available' }) }
|
||||
|
||||
scope :student_in_claimed_or_available,
|
||||
select(:course_id).
|
||||
scope :student_in_claimed_or_available, -> {
|
||||
select(:course_id).
|
||||
joins(:course).
|
||||
where(:type => 'StudentEnrollment', :workflow_state => 'active', :courses => { :workflow_state => ['available', 'claimed'] })
|
||||
where(:type => 'StudentEnrollment', :workflow_state => 'active', :courses => { :workflow_state => ['available', 'claimed'] }) }
|
||||
|
||||
scope :all_student,
|
||||
includes(:course).
|
||||
scope :all_student, -> {
|
||||
includes(:course).
|
||||
where("(enrollments.type = 'StudentEnrollment'
|
||||
AND enrollments.workflow_state IN ('invited', 'active', 'completed')
|
||||
AND courses.workflow_state IN ('available', 'completed')) OR
|
||||
(enrollments.type = 'StudentViewEnrollment'
|
||||
AND enrollments.workflow_state = 'active'
|
||||
AND courses.workflow_state != 'deleted')")
|
||||
AND courses.workflow_state != 'deleted')") }
|
||||
|
||||
scope :future, lambda {
|
||||
scope :future, -> {
|
||||
joins(:course).
|
||||
where("(courses.start_at>?
|
||||
AND courses.workflow_state='available'
|
||||
|
@ -191,16 +191,15 @@ class Enrollment < ActiveRecord::Base
|
|||
courses.workflow_state IN ('created', 'claimed')
|
||||
AND enrollments.type IN ('TeacherEnrollment','TaEnrollment', 'DesignerEnrollment')
|
||||
AND enrollments.workflow_state IN ('invited', 'active', 'creation_pending')
|
||||
)", Time.now.utc, true)
|
||||
}
|
||||
)", Time.now.utc, true) }
|
||||
|
||||
scope :past,
|
||||
joins(:course).
|
||||
scope :past, -> {
|
||||
joins(:course).
|
||||
where("(courses.workflow_state='completed'
|
||||
AND enrollments.workflow_state NOT IN ('invited', 'deleted'))
|
||||
OR enrollments.workflow_state IN ('rejected', 'completed')")
|
||||
OR enrollments.workflow_state IN ('rejected', 'completed')") }
|
||||
|
||||
scope :not_fake, where("enrollments.type<>'StudentViewEnrollment'")
|
||||
scope :not_fake, -> { where("enrollments.type<>'StudentViewEnrollment'") }
|
||||
|
||||
|
||||
def self.readable_types
|
||||
|
@ -883,7 +882,7 @@ class Enrollment < ActiveRecord::Base
|
|||
can :read_services
|
||||
end
|
||||
|
||||
scope :before, lambda{ |date|
|
||||
scope :before, lambda { |date|
|
||||
where("enrollments.created_at<?", date)
|
||||
}
|
||||
|
||||
|
@ -894,10 +893,10 @@ class Enrollment < ActiveRecord::Base
|
|||
joins(:user).
|
||||
select("user_id, course_id, users.name AS user_name")
|
||||
}
|
||||
scope :invited, where(:workflow_state => 'invited')
|
||||
scope :accepted, where("enrollments.workflow_state<>'invited'")
|
||||
scope :active_or_pending, where(:workflow_state => ['invited', 'creation_pending', 'active'])
|
||||
scope :currently_online, joins(:pseudonyms).where("pseudonyms.last_request_at>?", 5.minutes.ago)
|
||||
scope :invited, -> { where(:workflow_state => 'invited') }
|
||||
scope :accepted, -> { where("enrollments.workflow_state<>'invited'") }
|
||||
scope :active_or_pending, -> { where(:workflow_state => ['invited', 'creation_pending', 'active']) }
|
||||
scope :currently_online, -> { joins(:pseudonyms).where("pseudonyms.last_request_at>?", 5.minutes.ago) }
|
||||
# this returns enrollments for creation_pending users; should always be used in conjunction with the invited scope
|
||||
scope :for_email, lambda { |email|
|
||||
joins(:user => :communication_channels).
|
||||
|
|
|
@ -140,5 +140,5 @@ class EnrollmentTerm < ActiveRecord::Base
|
|||
save!
|
||||
end
|
||||
|
||||
scope :active, where("enrollment_terms.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("enrollment_terms.workflow_state<>'deleted'") }
|
||||
end
|
||||
|
|
|
@ -43,7 +43,7 @@ class Eportfolio < ActiveRecord::Base
|
|||
self.save
|
||||
end
|
||||
|
||||
scope :active, where("eportfolios.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("eportfolios.workflow_state<>'deleted'") }
|
||||
|
||||
before_create :assign_uuid
|
||||
def assign_uuid
|
||||
|
|
|
@ -52,7 +52,7 @@ class ExternalFeed < ActiveRecord::Base
|
|||
write_attribute(:header_match, str.to_s.strip.presence)
|
||||
end
|
||||
|
||||
scope :to_be_polled, lambda {
|
||||
scope :to_be_polled, -> {
|
||||
where("external_feeds.consecutive_failures<5 AND external_feeds.refresh_at<?", Time.now.utc).order(:refresh_at)
|
||||
}
|
||||
|
||||
|
|
|
@ -96,12 +96,12 @@ class Folder < ActiveRecord::Base
|
|||
self.save
|
||||
end
|
||||
|
||||
scope :active, where("folders.workflow_state<>'deleted'")
|
||||
scope :not_hidden, where("folders.workflow_state<>'hidden'")
|
||||
scope :not_locked, lambda { where("(folders.locked IS NULL OR folders.locked=?) AND ((folders.lock_at IS NULL) OR
|
||||
scope :active, -> { where("folders.workflow_state<>'deleted'") }
|
||||
scope :not_hidden, -> { where("folders.workflow_state<>'hidden'") }
|
||||
scope :not_locked, -> { where("(folders.locked IS NULL OR folders.locked=?) AND ((folders.lock_at IS NULL) OR
|
||||
(folders.lock_at>? OR (folders.unlock_at IS NOT NULL AND folders.unlock_at<?)))", false, Time.now.utc, Time.now.utc) }
|
||||
scope :by_position, order(:position)
|
||||
scope :by_name, lambda { order(name_order_by_clause('folders')) }
|
||||
scope :by_position, -> { order(:position) }
|
||||
scope :by_name, -> { order(name_order_by_clause('folders')) }
|
||||
|
||||
def display_name
|
||||
name
|
||||
|
|
|
@ -59,8 +59,8 @@ class GradingStandard < ActiveRecord::Base
|
|||
state :deleted
|
||||
end
|
||||
|
||||
scope :active, where("grading_standards.workflow_state<>'deleted'")
|
||||
scope :sorted, lambda { order("usage_count >= 3 DESC").order(nulls(:last, best_unicode_collation_key('title'))) }
|
||||
scope :active, -> { where("grading_standards.workflow_state<>'deleted'") }
|
||||
scope :sorted, -> { order("usage_count >= 3 DESC").order(nulls(:last, best_unicode_collation_key('title'))) }
|
||||
|
||||
VERSION = 2
|
||||
|
||||
|
|
|
@ -251,9 +251,9 @@ class Group < ActiveRecord::Base
|
|||
|
||||
Bookmarker = BookmarkedCollection::SimpleBookmarker.new(Group, :name, :id)
|
||||
|
||||
scope :active, where("groups.workflow_state<>'deleted'")
|
||||
scope :by_name, lambda { order(Bookmarker.order_by) }
|
||||
scope :uncategorized, where("groups.group_category_id IS NULL")
|
||||
scope :active, -> { where("groups.workflow_state<>'deleted'") }
|
||||
scope :by_name, -> { order(Bookmarker.order_by) }
|
||||
scope :uncategorized, -> { where("groups.group_category_id IS NULL") }
|
||||
|
||||
def full_name
|
||||
res = before_label(self.name) + " "
|
||||
|
|
|
@ -80,7 +80,7 @@ class GroupCategory < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
scope :active, where(:deleted_at => nil)
|
||||
scope :active, -> { where(:deleted_at => nil) }
|
||||
|
||||
scope :other_than, lambda { |cat| where("group_categories.id<>?", cat.id || 0) }
|
||||
|
||||
|
|
|
@ -45,10 +45,10 @@ class GroupMembership < ActiveRecord::Base
|
|||
|
||||
has_a_broadcast_policy
|
||||
|
||||
scope :include_user, includes(:user)
|
||||
scope :include_user, -> { includes(:user) }
|
||||
|
||||
scope :active, where("group_memberships.workflow_state<>'deleted'")
|
||||
scope :moderators, where(:moderator => true)
|
||||
scope :active, -> { where("group_memberships.workflow_state<>'deleted'") }
|
||||
scope :moderators, -> { where(:moderator => true) }
|
||||
|
||||
alias_method :context, :group
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ class InboxItem < ActiveRecord::Base
|
|||
attr_accessible :user_id, :asset, :subject, :body_teaser, :sender_id
|
||||
|
||||
# Named scopes
|
||||
scope :active, where("workflow_state NOT IN ('deleted', 'retired', 'retired_unread')")
|
||||
scope :unread, where(:workflow_state => 'unread')
|
||||
scope :active, -> { where("workflow_state NOT IN ('deleted', 'retired', 'retired_unread')") }
|
||||
scope :unread, -> { where(:workflow_state => 'unread') }
|
||||
|
||||
# State machine
|
||||
workflow do
|
||||
|
|
|
@ -207,13 +207,13 @@ class LearningOutcome < ActiveRecord::Base
|
|||
end
|
||||
|
||||
scope :for_context_codes, lambda { |codes| where(:context_code => codes) }
|
||||
scope :active, where("learning_outcomes.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("learning_outcomes.workflow_state<>'deleted'") }
|
||||
scope :has_result_for, lambda { |user|
|
||||
joins(:learning_outcome_results).
|
||||
where("learning_outcomes.id=learning_outcome_results.learning_outcome_id AND learning_outcome_results.user_id=?", user).
|
||||
order(best_unicode_collation_key('short_description'))
|
||||
}
|
||||
|
||||
scope :global, where(:context_id => nil)
|
||||
scope :global, -> { where(:context_id => nil) }
|
||||
|
||||
end
|
||||
|
|
|
@ -228,11 +228,11 @@ class LearningOutcomeGroup < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
scope :active, where("learning_outcome_groups.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("learning_outcome_groups.workflow_state<>'deleted'") }
|
||||
|
||||
scope :global, where(:context_id => nil)
|
||||
scope :global, -> { where(:context_id => nil) }
|
||||
|
||||
scope :root, where(:learning_outcome_group_id => nil)
|
||||
scope :root, -> { where(:learning_outcome_group_id => nil) }
|
||||
|
||||
def self.for_context(context)
|
||||
context ? context.learning_outcome_groups : LearningOutcomeGroup.global
|
||||
|
|
|
@ -336,7 +336,7 @@ class MediaObject < ActiveRecord::Base
|
|||
save!
|
||||
end
|
||||
|
||||
scope :active, where("media_objects.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("media_objects.workflow_state<>'deleted'") }
|
||||
|
||||
scope :by_media_id, lambda { |media_id| where("media_objects.media_id=? OR media_objects.old_media_id=?", media_id, media_id) }
|
||||
|
||||
|
|
|
@ -140,15 +140,15 @@ class Message < ActiveRecord::Base
|
|||
|
||||
scope :after, lambda { |date| where("messages.created_at>?", date) }
|
||||
|
||||
scope :to_dispatch, lambda {
|
||||
scope :to_dispatch, -> {
|
||||
where("messages.workflow_state='staged' AND messages.dispatch_at<=? AND 'messages.to'<>'dashboard'", Time.now.utc)
|
||||
}
|
||||
|
||||
scope :to_email, where(:path_type => ['email', 'sms'])
|
||||
scope :to_email, -> { where(:path_type => ['email', 'sms']) }
|
||||
|
||||
scope :to_facebook, where(:path_type => 'facebook', :workflow_state => 'sent').order("sent_at DESC").limit(25)
|
||||
scope :to_facebook, -> { where(:path_type => 'facebook', :workflow_state => 'sent').order("sent_at DESC").limit(25) }
|
||||
|
||||
scope :not_to_email, where("messages.path_type NOT IN ('email', 'sms')")
|
||||
scope :not_to_email, -> { where("messages.path_type NOT IN ('email', 'sms')") }
|
||||
|
||||
scope :by_name, lambda { |notification_name| where(:notification_name => notification_name) }
|
||||
|
||||
|
@ -158,13 +158,13 @@ class Message < ActiveRecord::Base
|
|||
|
||||
# messages that can be moved to the 'cancelled' state. dashboard messages
|
||||
# can be closed by calling 'cancel', but aren't included
|
||||
scope :cancellable, where(:workflow_state => ['created', 'staged', 'sending'])
|
||||
scope :cancellable, -> { where(:workflow_state => ['created', 'staged', 'sending']) }
|
||||
|
||||
# For finding a very particular message:
|
||||
# Message.for(context).by_name(name).directed_to(to).for_user(user), or
|
||||
# messages.for(context).by_name(name).directed_to(to).for_user(user)
|
||||
# Where user can be a User or id, name needs to be the Notification name.
|
||||
scope :staged, lambda { where("messages.workflow_state='staged' AND messages.dispatch_at>?", Time.now.utc) }
|
||||
scope :staged, -> { where("messages.workflow_state='staged' AND messages.dispatch_at>?", Time.now.utc) }
|
||||
|
||||
scope :in_state, lambda { |state| where(:workflow_state => Array(state).map(&:to_s)) }
|
||||
|
||||
|
|
|
@ -17,8 +17,8 @@ class MigrationIssue < ActiveRecord::Base
|
|||
state :resolved
|
||||
end
|
||||
|
||||
scope :active, where(:workflow_state => 'active')
|
||||
scope :by_created_at, order(:created_at)
|
||||
scope :active, -> { where(:workflow_state => 'active') }
|
||||
scope :by_created_at, -> { order(:created_at) }
|
||||
|
||||
set_policy do
|
||||
given { |user| Account.site_admin.grants_right?(user, :view_error_reports) }
|
||||
|
|
|
@ -52,7 +52,7 @@ class Notification < ActiveRecord::Base
|
|||
|
||||
attr_accessible :name, :subject, :main_link, :delay_for, :category
|
||||
|
||||
scope :to_show_in_feed, where("messages.category='TestImmediately' OR messages.notification_name IN (?)", TYPES_TO_SHOW_IN_FEED)
|
||||
scope :to_show_in_feed, -> { where("messages.category='TestImmediately' OR messages.notification_name IN (?)", TYPES_TO_SHOW_IN_FEED) }
|
||||
|
||||
validates_uniqueness_of :name
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ class Pseudonym < ActiveRecord::Base
|
|||
nil
|
||||
end
|
||||
|
||||
scope :active, where(workflow_state: 'active')
|
||||
scope :active, -> { where(workflow_state: 'active') }
|
||||
|
||||
def self.serialization_excludes; [:crypted_password, :password_salt, :reset_password_token, :persistence_token, :single_access_token, :perishable_token, :sis_ssha]; end
|
||||
|
||||
|
|
|
@ -1062,11 +1062,11 @@ class Quizzes::Quiz < ActiveRecord::Base
|
|||
can :read and can :submit
|
||||
end
|
||||
|
||||
scope :include_assignment, includes(:assignment)
|
||||
scope :include_assignment, -> { includes(:assignment) }
|
||||
scope :before, lambda { |date| where("quizzes.created_at<?", date) }
|
||||
scope :active, where("quizzes.workflow_state<>'deleted'")
|
||||
scope :not_for_assignment, where(:assignment_id => nil)
|
||||
scope :available, where("quizzes.workflow_state = 'available'")
|
||||
scope :active, -> { where("quizzes.workflow_state<>'deleted'") }
|
||||
scope :not_for_assignment, -> { where(:assignment_id => nil) }
|
||||
scope :available, -> { where("quizzes.workflow_state = 'available'") }
|
||||
|
||||
def teachers
|
||||
context.teacher_enrollments.map(&:user)
|
||||
|
|
|
@ -43,7 +43,7 @@ class Quizzes::QuizQuestion < ActiveRecord::Base
|
|||
state :deleted
|
||||
end
|
||||
|
||||
scope :active, where("workflow_state='active' OR workflow_state IS NULL")
|
||||
scope :active, -> { where("workflow_state='active' OR workflow_state IS NULL") }
|
||||
|
||||
def infer_defaults
|
||||
if !self.position && self.quiz
|
||||
|
|
|
@ -641,9 +641,9 @@ class Quizzes::QuizSubmission < ActiveRecord::Base
|
|||
date ? where("quiz_submissions.updated_at>?", date) : scoped
|
||||
}
|
||||
scope :for_user_ids, lambda { |user_ids| where(:user_id => user_ids) }
|
||||
scope :logged_out, where("temporary_user_code is not null")
|
||||
scope :not_settings_only, where("quiz_submissions.workflow_state<>'settings_only'")
|
||||
scope :completed, where(:workflow_state => %w(complete pending_review))
|
||||
scope :logged_out, -> { where("temporary_user_code is not null") }
|
||||
scope :not_settings_only, -> { where("quiz_submissions.workflow_state<>'settings_only'") }
|
||||
scope :completed, -> { where(:workflow_state => %w(complete pending_review)) }
|
||||
|
||||
has_a_broadcast_policy
|
||||
|
||||
|
|
|
@ -74,10 +74,10 @@ class ReportSnapshot < ActiveRecord::Base
|
|||
write_attribute(:data, data.to_json)
|
||||
end
|
||||
|
||||
scope :detailed, where(:report_type => 'counts_detailed')
|
||||
scope :progressive, where(:report_type => 'counts_progressive_detailed')
|
||||
scope :overview, where(:report_type => 'counts_overview')
|
||||
scope :progressive_overview, where(:report_type => 'counts_progressive_overview')
|
||||
scope :detailed, -> { where(:report_type => 'counts_detailed') }
|
||||
scope :progressive, -> { where(:report_type => 'counts_progressive_detailed') }
|
||||
scope :overview, -> { where(:report_type => 'counts_overview') }
|
||||
scope :progressive_overview, -> { where(:report_type => 'counts_progressive_overview') }
|
||||
|
||||
def push_to_instructure_if_collection_enabled
|
||||
begin
|
||||
|
|
|
@ -75,12 +75,12 @@ class Role < ActiveRecord::Base
|
|||
save!
|
||||
end
|
||||
|
||||
scope :not_deleted, where("roles.workflow_state<>'deleted'")
|
||||
scope :deleted, where(:workflow_state => 'deleted')
|
||||
scope :active, where(:workflow_state => 'active')
|
||||
scope :inactive, where(:workflow_state => 'inactive')
|
||||
scope :for_courses, where("roles.base_role_type<>?", AccountUser::BASE_ROLE_NAME)
|
||||
scope :for_accounts, where(:base_role_type => AccountUser::BASE_ROLE_NAME)
|
||||
scope :not_deleted, -> { where("roles.workflow_state<>'deleted'") }
|
||||
scope :deleted, -> { where(:workflow_state => 'deleted') }
|
||||
scope :active, -> { where(:workflow_state => 'active') }
|
||||
scope :inactive, -> { where(:workflow_state => 'inactive') }
|
||||
scope :for_courses, -> { where("roles.base_role_type<>?", AccountUser::BASE_ROLE_NAME) }
|
||||
scope :for_accounts, -> { where(:base_role_type => AccountUser::BASE_ROLE_NAME) }
|
||||
|
||||
def self.is_base_role?(role_name)
|
||||
RoleOverride.base_role_types.include?(role_name)
|
||||
|
|
|
@ -45,10 +45,10 @@ class Rubric < ActiveRecord::Base
|
|||
serialize :data
|
||||
simply_versioned
|
||||
|
||||
scope :publicly_reusable, lambda { where(:reusable => true).order(best_unicode_collation_key('title')) }
|
||||
scope :publicly_reusable, -> { where(:reusable => true).order(best_unicode_collation_key('title')) }
|
||||
scope :matching, lambda { |search| where(wildcard('rubrics.title', search)).order("rubrics.association_count DESC") }
|
||||
scope :before, lambda { |date| where("rubrics.created_at<?", date) }
|
||||
scope :active, where("workflow_state<>'deleted'")
|
||||
scope :active, -> { where("workflow_state<>'deleted'") }
|
||||
|
||||
set_policy do
|
||||
given {|user, session| self.context.grants_right?(user, session, :manage_rubrics)}
|
||||
|
|
|
@ -82,11 +82,11 @@ class RubricAssociation < ActiveRecord::Base
|
|||
}
|
||||
end
|
||||
|
||||
scope :bookmarked, where(:bookmarked => true)
|
||||
scope :bookmarked, -> { where(:bookmarked => true) }
|
||||
scope :for_purpose, lambda { |purpose| where(:purpose => purpose) }
|
||||
scope :for_grading, where(:purpose => 'grading')
|
||||
scope :for_grading, -> { where(:purpose => 'grading') }
|
||||
scope :for_context_codes, lambda { |codes| where(:context_code => codes) }
|
||||
scope :include_rubric, includes(:rubric)
|
||||
scope :include_rubric, -> { includes(:rubric) }
|
||||
scope :before, lambda { |date| where("rubric_associations.created_at<?", date) }
|
||||
|
||||
def assert_uniqueness
|
||||
|
|
|
@ -141,8 +141,8 @@ class SisBatch < ActiveRecord::Base
|
|||
self.save
|
||||
end
|
||||
|
||||
scope :needs_processing, where(:workflow_state => 'created').order(:created_at)
|
||||
scope :importing, where(:workflow_state => 'importing')
|
||||
scope :needs_processing, -> { where(:workflow_state => 'created').order(:created_at) }
|
||||
scope :importing, -> { where(:workflow_state => 'importing') }
|
||||
|
||||
def self.process_all_for_account(account)
|
||||
loop do
|
||||
|
|
|
@ -65,12 +65,12 @@ class Submission < ActiveRecord::Base
|
|||
include CustomValidations
|
||||
validates_as_url :url
|
||||
|
||||
scope :with_comments, includes(:submission_comments)
|
||||
scope :with_comments, -> { includes(:submission_comments) }
|
||||
scope :after, lambda { |date| where("submissions.created_at>?", date) }
|
||||
scope :before, lambda { |date| where("submissions.created_at<?", date) }
|
||||
scope :submitted_before, lambda { |date| where("submitted_at<?", date) }
|
||||
scope :submitted_after, lambda { |date| where("submitted_at>?", date) }
|
||||
scope :with_point_data, where("submissions.score IS NOT NULL OR submissions.grade IS NOT NULL")
|
||||
scope :with_point_data, -> { where("submissions.score IS NOT NULL OR submissions.grade IS NOT NULL") }
|
||||
|
||||
scope :for_context_codes, lambda { |context_codes| where(:context_code => context_codes) }
|
||||
|
||||
|
@ -104,7 +104,7 @@ class Submission < ActiveRecord::Base
|
|||
conditions
|
||||
end
|
||||
|
||||
scope :needs_grading, where(needs_grading_conditions)
|
||||
scope :needs_grading, -> { where(needs_grading_conditions) }
|
||||
|
||||
|
||||
sanitize_field :body, CanvasSanitize::SANITIZE
|
||||
|
@ -753,23 +753,23 @@ class Submission < ActiveRecord::Base
|
|||
state :graded
|
||||
end
|
||||
|
||||
scope :graded, where("submissions.grade IS NOT NULL")
|
||||
scope :graded, -> { where("submissions.grade IS NOT NULL") }
|
||||
|
||||
scope :ungraded, where(:grade => nil).includes(:assignment)
|
||||
scope :ungraded, -> { where(:grade => nil).includes(:assignment) }
|
||||
|
||||
scope :in_workflow_state, lambda { |provided_state| where(:workflow_state => provided_state) }
|
||||
|
||||
scope :having_submission, where("submissions.submission_type IS NOT NULL")
|
||||
scope :without_submission, where(submission_type: nil, workflow_state: "unsubmitted")
|
||||
scope :having_submission, -> { where("submissions.submission_type IS NOT NULL") }
|
||||
scope :without_submission, -> { where(submission_type: nil, workflow_state: "unsubmitted") }
|
||||
|
||||
scope :include_user, includes(:user)
|
||||
scope :include_user, -> { includes(:user) }
|
||||
|
||||
scope :include_assessment_requests, includes(:assessment_requests, :assigned_assessments)
|
||||
scope :include_versions, includes(:versions)
|
||||
scope :include_submission_comments, includes(:submission_comments)
|
||||
scope :speed_grader_includes, includes(:versions, :submission_comments, :attachments, :rubric_assessment)
|
||||
scope :include_assessment_requests, -> { includes(:assessment_requests, :assigned_assessments) }
|
||||
scope :include_versions, -> { includes(:versions) }
|
||||
scope :include_submission_comments, -> { includes(:submission_comments) }
|
||||
scope :speed_grader_includes, -> { includes(:versions, :submission_comments, :attachments, :rubric_assessment) }
|
||||
scope :for_user, lambda { |user| where(:user_id => user) }
|
||||
scope :needing_screenshot, where("submissions.submission_type='online_url' AND submissions.attachment_id IS NULL AND submissions.process_attempts<3").order(:updated_at)
|
||||
scope :needing_screenshot, -> { where("submissions.submission_type='online_url' AND submissions.attachment_id IS NULL AND submissions.process_attempts<3").order(:updated_at) }
|
||||
|
||||
def needs_regrading?
|
||||
graded? && !grade_matches_current_submission?
|
||||
|
|
|
@ -223,7 +223,7 @@ class SubmissionComment < ActiveRecord::Base
|
|||
context.root_account.service_enabled?(:avatars) ? [:avatar_path] : []
|
||||
end
|
||||
|
||||
scope :visible, where(:hidden => false)
|
||||
scope :visible, -> { where(:hidden => false) }
|
||||
|
||||
scope :after, lambda { |date| where("submission_comments.created_at>?", date) }
|
||||
scope :for_context, lambda { |context| where(:context_id => context, :context_type => context.class.to_s) }
|
||||
|
|
|
@ -186,13 +186,13 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
scope :of_account, lambda { |account| where("EXISTS (?)", account.user_account_associations.where("user_account_associations.user_id=users.id")).shard(account.shard) }
|
||||
scope :recently_logged_in, lambda {
|
||||
scope :recently_logged_in, -> {
|
||||
includes(:pseudonyms).
|
||||
where("pseudonyms.current_login_at>?", 1.month.ago).
|
||||
order("pseudonyms.current_login_at DESC").
|
||||
limit(25)
|
||||
}
|
||||
scope :include_pseudonym, includes(:pseudonym)
|
||||
scope :include_pseudonym, -> { includes(:pseudonym) }
|
||||
scope :restrict_to_sections, lambda { |sections|
|
||||
if sections.empty?
|
||||
scoped
|
||||
|
@ -203,9 +203,9 @@ class User < ActiveRecord::Base
|
|||
scope :name_like, lambda { |name|
|
||||
where("#{wildcard('users.name', 'users.short_name', name)} OR EXISTS (?)", Pseudonym.where(wildcard('pseudonyms.sis_user_id', 'pseudonyms.unique_id', name)).where("pseudonyms.user_id=users.id").active)
|
||||
}
|
||||
scope :active, where("users.workflow_state<>'deleted'")
|
||||
scope :active, -> { where("users.workflow_state<>'deleted'") }
|
||||
|
||||
scope :has_current_student_enrollments, where("EXISTS (SELECT * FROM enrollments JOIN courses ON courses.id=enrollments.course_id AND courses.workflow_state='available' WHERE enrollments.user_id=users.id AND enrollments.workflow_state IN ('active','invited') AND enrollments.type='StudentEnrollment')")
|
||||
scope :has_current_student_enrollments, -> { where("EXISTS (SELECT * FROM enrollments JOIN courses ON courses.id=enrollments.course_id AND courses.workflow_state='available' WHERE enrollments.user_id=users.id AND enrollments.workflow_state IN ('active','invited') AND enrollments.type='StudentEnrollment')") }
|
||||
|
||||
def self.order_by_sortable_name(options = {})
|
||||
order_clause = clause = sortable_name_order_by_clause
|
||||
|
|
|
@ -37,8 +37,8 @@ class UserNote < ActiveRecord::Base
|
|||
state :deleted
|
||||
end
|
||||
|
||||
scope :active, where("workflow_state<>'deleted'")
|
||||
scope :desc_by_date, order('created_at DESC')
|
||||
scope :active, -> { where("workflow_state<>'deleted'") }
|
||||
scope :desc_by_date, -> { order('created_at DESC') }
|
||||
|
||||
set_policy do
|
||||
given { |user| self.creator == user }
|
||||
|
|
|
@ -79,13 +79,13 @@ class UserService < ActiveRecord::Base
|
|||
|
||||
scope :of_type, lambda { |type| where(:type => type.to_s) }
|
||||
|
||||
scope :to_be_polled, lambda { where("refresh_at<", Time.now.utc).order(:refresh_at).limit(1) }
|
||||
scope :to_be_polled, -> { where("refresh_at<", Time.now.utc).order(:refresh_at).limit(1) }
|
||||
scope :for_user, lambda { |user| where(:user_id => user) }
|
||||
scope :for_service, lambda { |service|
|
||||
service = service.service if service.is_a?(UserService)
|
||||
where(:service => service.to_s)
|
||||
}
|
||||
scope :visible, where("visible")
|
||||
scope :visible, -> { where("visible") }
|
||||
|
||||
def service_name
|
||||
self.service.titleize rescue ""
|
||||
|
|
|
@ -48,7 +48,7 @@ class WebConference < ActiveRecord::Base
|
|||
|
||||
scope :for_context_codes, lambda { |context_codes| where(:context_code => context_codes) }
|
||||
|
||||
scope :with_config, lambda { where(conference_type: WebConference.conference_types.map{|ct| ct['conference_type']}) }
|
||||
scope :with_config, -> { where(conference_type: WebConference.conference_types.map{|ct| ct['conference_type']}) }
|
||||
|
||||
serialize :settings
|
||||
def settings
|
||||
|
@ -418,7 +418,7 @@ class WebConference < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
scope :active, scoped
|
||||
scope :active, -> { scoped }
|
||||
|
||||
def as_json(options={})
|
||||
url = options.delete(:url)
|
||||
|
|
|
@ -217,21 +217,21 @@ class WikiPage < ActiveRecord::Base
|
|||
self.versions.map(&:model)
|
||||
end
|
||||
|
||||
scope :active, where(:workflow_state => 'active')
|
||||
scope :active, -> { where(:workflow_state => 'active') }
|
||||
|
||||
scope :deleted_last, order("workflow_state='deleted'")
|
||||
scope :deleted_last, -> { order("workflow_state='deleted'") }
|
||||
|
||||
scope :not_deleted, where("wiki_pages.workflow_state<>'deleted'")
|
||||
scope :not_deleted, -> { where("wiki_pages.workflow_state<>'deleted'") }
|
||||
|
||||
scope :published, where("wiki_pages.workflow_state='active' AND (wiki_pages.hide_from_students=? OR wiki_pages.hide_from_students IS NULL)", false)
|
||||
scope :unpublished, where("wiki_pages.workflow_state='unpublished' OR (wiki_pages.hide_from_students=? AND wiki_pages.workflow_state<>'deleted')", true)
|
||||
scope :published, -> { where("wiki_pages.workflow_state='active' AND (wiki_pages.hide_from_students=? OR wiki_pages.hide_from_students IS NULL)", false) }
|
||||
scope :unpublished, -> { where("wiki_pages.workflow_state='unpublished' OR (wiki_pages.hide_from_students=? AND wiki_pages.workflow_state<>'deleted')", true) }
|
||||
|
||||
# needed for ensure_unique_url
|
||||
def not_deleted
|
||||
!deleted?
|
||||
end
|
||||
|
||||
scope :order_by_id, order(:id)
|
||||
scope :order_by_id, -> { order(:id) }
|
||||
|
||||
def locked_for?(user, opts={})
|
||||
return false unless self.could_be_locked
|
||||
|
|
|
@ -886,9 +886,9 @@ class ActiveRecord::Base
|
|||
|
||||
if Rails.version < '4'
|
||||
if CANVAS_RAILS2
|
||||
named_scope :none, lambda { where("?", false) }
|
||||
named_scope :none, -> { where("?", false) }
|
||||
else
|
||||
scope :none, lambda { {:conditions => ["?", false]} }
|
||||
scope :none, -> { {:conditions => ["?", false]} }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue