2017-07-09 13:41:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-06 12:26:20 -04:00
|
|
|
require "ostruct"
|
2011-04-18 18:35:22 -04:00
|
|
|
|
2019-04-29 06:31:41 -04:00
|
|
|
class Developer < ActiveRecord::Base
|
2020-05-31 15:09:24 -04:00
|
|
|
module TimestampAliases
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
alias_attribute :created_at, :legacy_created_at
|
|
|
|
alias_attribute :updated_at, :legacy_updated_at
|
|
|
|
alias_attribute :created_on, :legacy_created_on
|
|
|
|
alias_attribute :updated_on, :legacy_updated_on
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
include TimestampAliases
|
|
|
|
|
2019-04-29 06:31:41 -04:00
|
|
|
module ProjectsAssociationExtension2
|
|
|
|
def find_least_recent
|
|
|
|
order("id ASC").first
|
|
|
|
end
|
2006-04-10 21:10:42 -04:00
|
|
|
end
|
|
|
|
|
2015-09-22 14:10:38 -04:00
|
|
|
self.ignored_columns = %w(first_name last_name)
|
|
|
|
|
2005-11-06 14:05:42 -05:00
|
|
|
has_and_belongs_to_many :projects do
|
2005-11-03 04:06:42 -05:00
|
|
|
def find_most_recent
|
2012-07-27 12:27:47 -04:00
|
|
|
order("id DESC").first
|
2005-11-03 04:06:42 -05:00
|
|
|
end
|
2005-11-06 14:05:42 -05:00
|
|
|
end
|
2008-01-18 02:27:03 -05:00
|
|
|
|
2015-04-28 08:51:51 -04:00
|
|
|
belongs_to :mentor
|
2020-02-21 13:11:24 -05:00
|
|
|
belongs_to :strict_loading_mentor, strict_loading: true, foreign_key: :mentor_id, class_name: "Mentor"
|
2021-03-16 16:21:35 -04:00
|
|
|
belongs_to :strict_loading_off_mentor, strict_loading: false, foreign_key: :mentor_id, class_name: "Mentor"
|
2015-04-28 08:51:51 -04:00
|
|
|
|
2014-05-08 01:57:49 -04:00
|
|
|
accepts_nested_attributes_for :projects
|
|
|
|
|
2014-10-08 16:58:11 -04:00
|
|
|
has_and_belongs_to_many :shared_computers, class_name: "Computer"
|
|
|
|
|
2008-01-18 02:27:03 -05:00
|
|
|
has_and_belongs_to_many :projects_extended_by_name,
|
2019-04-29 06:31:41 -04:00
|
|
|
-> { extending(ProjectsAssociationExtension) },
|
2016-08-06 13:37:57 -04:00
|
|
|
class_name: "Project",
|
|
|
|
join_table: "developers_projects",
|
|
|
|
association_foreign_key: "project_id"
|
2005-11-03 04:06:42 -05:00
|
|
|
|
2008-01-18 02:27:03 -05:00
|
|
|
has_and_belongs_to_many :projects_extended_by_name_twice,
|
2019-04-29 06:31:41 -04:00
|
|
|
-> { extending(ProjectsAssociationExtension, ProjectsAssociationExtension2) },
|
2016-08-06 13:37:57 -04:00
|
|
|
class_name: "Project",
|
|
|
|
join_table: "developers_projects",
|
|
|
|
association_foreign_key: "project_id"
|
2006-04-10 21:10:42 -04:00
|
|
|
|
2008-01-18 02:27:03 -05:00
|
|
|
has_and_belongs_to_many :projects_extended_by_name_and_block,
|
2019-04-29 06:31:41 -04:00
|
|
|
-> { extending(ProjectsAssociationExtension) },
|
2016-08-06 13:37:57 -04:00
|
|
|
class_name: "Project",
|
|
|
|
join_table: "developers_projects",
|
|
|
|
association_foreign_key: "project_id" do
|
2007-09-17 17:19:44 -04:00
|
|
|
def find_least_recent
|
2012-07-27 12:27:47 -04:00
|
|
|
order("id ASC").first
|
2007-09-17 17:19:44 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-02-21 13:11:24 -05:00
|
|
|
has_and_belongs_to_many :strict_loading_projects,
|
|
|
|
join_table: :developers_projects,
|
|
|
|
association_foreign_key: :project_id,
|
|
|
|
class_name: "Project",
|
|
|
|
strict_loading: true
|
|
|
|
|
2016-08-06 13:37:57 -04:00
|
|
|
has_and_belongs_to_many :special_projects, join_table: "developers_projects", association_foreign_key: "project_id"
|
2013-12-12 13:43:36 -05:00
|
|
|
has_and_belongs_to_many :sym_special_projects,
|
2016-08-06 13:37:57 -04:00
|
|
|
join_table: :developers_projects,
|
|
|
|
association_foreign_key: "project_id",
|
|
|
|
class_name: "SpecialProject"
|
2005-10-06 13:13:24 -04:00
|
|
|
|
2007-10-10 02:45:13 -04:00
|
|
|
has_many :audit_logs
|
2020-12-09 13:42:24 -05:00
|
|
|
has_many :required_audit_logs, class_name: "AuditLogRequired"
|
2019-07-17 09:55:06 -04:00
|
|
|
has_many :strict_loading_audit_logs, -> { strict_loading }, class_name: "AuditLog"
|
2020-02-21 13:11:24 -05:00
|
|
|
has_many :strict_loading_opt_audit_logs, strict_loading: true, class_name: "AuditLog"
|
2013-09-27 19:56:49 -04:00
|
|
|
has_many :contracts
|
2016-08-06 13:37:57 -04:00
|
|
|
has_many :firms, through: :contracts, source: :firm
|
2014-07-14 20:25:18 -04:00
|
|
|
has_many :comments, ->(developer) { where(body: "I'm #{developer.name}") }
|
|
|
|
has_many :ratings, through: :comments
|
2020-02-21 13:11:24 -05:00
|
|
|
|
2015-08-24 04:27:06 -04:00
|
|
|
has_one :ship, dependent: :nullify
|
2020-02-21 13:11:24 -05:00
|
|
|
has_one :strict_loading_ship, strict_loading: true, class_name: "Ship"
|
2007-10-10 02:45:13 -04:00
|
|
|
|
2015-09-26 16:07:24 -04:00
|
|
|
belongs_to :firm
|
|
|
|
has_many :contracted_projects, class_name: "Project"
|
|
|
|
|
2016-08-06 13:37:57 -04:00
|
|
|
scope :jamises, -> { where(name: "Jamis") }
|
2008-08-21 11:08:42 -04:00
|
|
|
|
2016-08-06 13:37:57 -04:00
|
|
|
validates_inclusion_of :salary, in: 50000..200000
|
|
|
|
validates_length_of :name, within: 3..20
|
2007-10-10 02:45:13 -04:00
|
|
|
|
|
|
|
before_create do |developer|
|
2016-08-06 13:37:57 -04:00
|
|
|
developer.audit_logs.build message: "Computer created"
|
2007-10-10 02:45:13 -04:00
|
|
|
end
|
2008-05-08 01:04:53 -04:00
|
|
|
|
2020-01-28 19:53:14 -05:00
|
|
|
attribute :last_name
|
2015-09-22 14:10:38 -04:00
|
|
|
|
2008-05-08 01:04:53 -04:00
|
|
|
def log=(message)
|
2016-08-06 13:37:57 -04:00
|
|
|
audit_logs.build message: message
|
2008-05-08 01:04:53 -04:00
|
|
|
end
|
2012-12-02 15:24:47 -05:00
|
|
|
|
|
|
|
after_find :track_instance_count
|
|
|
|
cattr_accessor :instance_count
|
|
|
|
|
|
|
|
def track_instance_count
|
|
|
|
self.class.instance_count ||= 0
|
|
|
|
self.class.instance_count += 1
|
|
|
|
end
|
|
|
|
private :track_instance_count
|
2007-10-10 02:45:13 -04:00
|
|
|
end
|
|
|
|
|
2017-10-19 08:07:56 -04:00
|
|
|
class SubDeveloper < Developer
|
|
|
|
end
|
|
|
|
|
2021-01-04 20:35:36 -05:00
|
|
|
class SpecialDeveloper < ActiveRecord::Base
|
|
|
|
self.table_name = "developers"
|
|
|
|
has_many :special_contracts, foreign_key: "developer_id"
|
|
|
|
end
|
|
|
|
|
2017-10-19 03:30:31 -04:00
|
|
|
class SymbolIgnoredDeveloper < ActiveRecord::Base
|
|
|
|
self.table_name = "developers"
|
|
|
|
self.ignored_columns = [:first_name, :last_name]
|
|
|
|
|
2020-01-28 19:53:14 -05:00
|
|
|
attribute :last_name
|
2017-10-19 03:30:31 -04:00
|
|
|
end
|
|
|
|
|
2007-10-10 02:45:13 -04:00
|
|
|
class AuditLog < ActiveRecord::Base
|
2016-08-06 13:37:57 -04:00
|
|
|
belongs_to :developer, validate: true
|
|
|
|
belongs_to :unvalidated_developer, class_name: "Developer"
|
2004-12-15 20:32:35 -05:00
|
|
|
end
|
2005-05-19 12:39:50 -04:00
|
|
|
|
2020-12-09 13:42:24 -05:00
|
|
|
class AuditLogRequired < ActiveRecord::Base
|
|
|
|
self.table_name = "audit_logs"
|
|
|
|
belongs_to :developer, required: true
|
|
|
|
end
|
|
|
|
|
2005-11-08 05:19:09 -05:00
|
|
|
class DeveloperWithBeforeDestroyRaise < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
has_and_belongs_to_many :projects, join_table: "developers_projects", foreign_key: "developer_id"
|
2005-11-08 05:19:09 -05:00
|
|
|
before_destroy :raise_if_projects_empty!
|
|
|
|
|
|
|
|
def raise_if_projects_empty!
|
|
|
|
raise if projects.empty?
|
|
|
|
end
|
|
|
|
end
|
2008-11-16 13:06:41 -05:00
|
|
|
|
2011-05-29 11:38:01 -04:00
|
|
|
class DeveloperWithSelect < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
|
|
|
default_scope { select("name") }
|
2011-05-29 11:38:01 -04:00
|
|
|
end
|
|
|
|
|
2020-11-19 17:20:45 -05:00
|
|
|
class DeveloperwithDefaultMentorScopeNot < ActiveRecord::Base
|
|
|
|
self.table_name = "developers"
|
|
|
|
default_scope -> { where(mentor_id: 1) }
|
|
|
|
end
|
|
|
|
|
|
|
|
class DeveloperWithDefaultMentorScopeAllQueries < ActiveRecord::Base
|
|
|
|
self.table_name = "developers"
|
|
|
|
default_scope -> { where(mentor_id: 1) }, all_queries: true
|
|
|
|
end
|
|
|
|
|
2021-09-16 14:12:11 -04:00
|
|
|
class DeveloperWithDefaultNilableMentorScopeAllQueries < ActiveRecord::Base
|
|
|
|
self.table_name = "developers"
|
|
|
|
firm_id = nil # Could be something like Current.mentor_id
|
|
|
|
default_scope -> { where(firm_id: firm_id) if firm_id }, all_queries: true
|
|
|
|
end
|
|
|
|
|
2011-06-23 14:57:49 -04:00
|
|
|
class DeveloperWithIncludes < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
has_many :audit_logs, foreign_key: :developer_id
|
2012-03-21 18:18:18 -04:00
|
|
|
default_scope { includes(:audit_logs) }
|
2011-06-23 14:57:49 -04:00
|
|
|
end
|
|
|
|
|
2013-01-11 12:29:30 -05:00
|
|
|
class DeveloperFilteredOnJoins < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
has_and_belongs_to_many :projects, -> { order("projects.id") }, foreign_key: "developer_id", join_table: "developers_projects"
|
2013-01-11 12:29:30 -05:00
|
|
|
|
|
|
|
def self.default_scope
|
2016-08-06 13:37:57 -04:00
|
|
|
joins(:projects).where(projects: { name: "Active Controller" })
|
2013-01-11 12:29:30 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-11-16 13:06:41 -05:00
|
|
|
class DeveloperOrderedBySalary < ActiveRecord::Base
|
Support `where` with comparison operators (`>`, `>=`, `<`, and `<=`)
```ruby
posts = Post.order(:id)
posts.where("id >": 9).pluck(:id) # => [10, 11]
posts.where("id >=": 9).pluck(:id) # => [9, 10, 11]
posts.where("id <": 3).pluck(:id) # => [1, 2]
posts.where("id <=": 3).pluck(:id) # => [1, 2, 3]
```
From type casting and table/column name resolution's point of view,
`where("create_at >=": time)` is better alternative than `where("create_at >= ?", time)`.
```ruby
class Post < ActiveRecord::Base
attribute :created_at, :datetime, precision: 3
end
time = Time.now.utc # => 2020-06-24 10:11:12.123456 UTC
Post.create!(created_at: time) # => #<Post id: 1, created_at: "2020-06-24 10:11:12.123000">
# SELECT `posts`.* FROM `posts` WHERE (created_at >= '2020-06-24 10:11:12.123456')
Post.where("created_at >= ?", time) # => []
# SELECT `posts`.* FROM `posts` WHERE `posts`.`created_at` >= '2020-06-24 10:11:12.123000'
Post.where("created_at >=": time) # => [#<Post id: 1, created_at: "2020-06-24 10:11:12.123000">]
```
2020-06-13 04:57:59 -04:00
|
|
|
include Developer::TimestampAliases
|
|
|
|
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
|
|
|
default_scope { order("salary DESC") }
|
2011-04-03 19:07:45 -04:00
|
|
|
|
2016-08-06 12:26:20 -04:00
|
|
|
scope :by_name, -> { order("name DESC") }
|
2008-11-16 13:06:41 -05:00
|
|
|
end
|
2009-05-18 15:27:42 -04:00
|
|
|
|
|
|
|
class DeveloperCalledDavid < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2012-03-21 18:18:18 -04:00
|
|
|
default_scope { where("name = 'David'") }
|
2009-05-18 15:27:42 -04:00
|
|
|
end
|
|
|
|
|
2011-04-18 18:35:22 -04:00
|
|
|
class LazyLambdaDeveloperCalledDavid < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
default_scope lambda { where(name: "David") }
|
2011-04-18 18:35:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class LazyBlockDeveloperCalledDavid < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
default_scope { where(name: "David") }
|
2011-04-18 18:35:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class CallableDeveloperCalledDavid < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
default_scope OpenStruct.new(call: where(name: "David"))
|
2011-04-18 18:35:22 -04:00
|
|
|
end
|
|
|
|
|
2011-04-18 18:15:38 -04:00
|
|
|
class ClassMethodDeveloperCalledDavid < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2011-04-03 19:07:45 -04:00
|
|
|
|
|
|
|
def self.default_scope
|
2016-08-06 13:37:57 -04:00
|
|
|
where(name: "David")
|
2011-04-03 19:07:45 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-05-24 19:07:38 -04:00
|
|
|
class ClassMethodReferencingScopeDeveloperCalledDavid < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
scope :david, -> { where(name: "David") }
|
2011-05-24 19:07:38 -04:00
|
|
|
|
|
|
|
def self.default_scope
|
|
|
|
david
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class LazyBlockReferencingScopeDeveloperCalledDavid < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
scope :david, -> { where(name: "David") }
|
2011-05-24 19:07:38 -04:00
|
|
|
default_scope { david }
|
|
|
|
end
|
|
|
|
|
2011-04-18 18:15:38 -04:00
|
|
|
class DeveloperCalledJamis < ActiveRecord::Base
|
2020-05-31 15:09:24 -04:00
|
|
|
include Developer::TimestampAliases
|
|
|
|
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2011-04-28 12:46:26 -04:00
|
|
|
|
2016-08-06 13:37:57 -04:00
|
|
|
default_scope { where(name: "Jamis") }
|
2016-08-06 12:26:20 -04:00
|
|
|
scope :poor, -> { where("salary < 150000") }
|
2014-02-23 06:14:05 -05:00
|
|
|
scope :david, -> { where name: "David" }
|
|
|
|
scope :david2, -> { unscoped.where name: "David" }
|
2009-05-18 15:27:42 -04:00
|
|
|
end
|
2010-02-26 05:06:55 -05:00
|
|
|
|
|
|
|
class PoorDeveloperCalledJamis < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2011-04-28 12:46:26 -04:00
|
|
|
|
2016-08-06 13:37:57 -04:00
|
|
|
default_scope -> { where(name: "Jamis", salary: 50000) }
|
2011-04-03 19:07:45 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class InheritedPoorDeveloperCalledJamis < DeveloperCalledJamis
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2011-04-03 19:07:45 -04:00
|
|
|
|
2016-08-06 13:37:57 -04:00
|
|
|
default_scope -> { where(salary: 50000) }
|
2011-04-03 19:07:45 -04:00
|
|
|
end
|
|
|
|
|
2011-04-18 18:15:38 -04:00
|
|
|
class MultiplePoorDeveloperCalledJamis < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2011-04-28 12:46:26 -04:00
|
|
|
|
2019-02-27 10:24:23 -05:00
|
|
|
default_scope { }
|
2016-08-06 13:37:57 -04:00
|
|
|
default_scope -> { where(name: "Jamis") }
|
|
|
|
default_scope -> { where(salary: 50000) }
|
2011-04-28 12:46:26 -04:00
|
|
|
end
|
2011-04-03 19:07:45 -04:00
|
|
|
|
2011-04-28 12:46:26 -04:00
|
|
|
module SalaryDefaultScope
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
2016-08-06 13:37:57 -04:00
|
|
|
included { default_scope { where(salary: 50000) } }
|
2010-06-28 17:17:56 -04:00
|
|
|
end
|
2011-04-28 12:46:26 -04:00
|
|
|
|
|
|
|
class ModuleIncludedPoorDeveloperCalledJamis < DeveloperCalledJamis
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2011-04-28 12:46:26 -04:00
|
|
|
|
|
|
|
include SalaryDefaultScope
|
|
|
|
end
|
|
|
|
|
2011-05-23 22:05:06 -04:00
|
|
|
class EagerDeveloperWithDefaultScope < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
has_and_belongs_to_many :projects, -> { order("projects.id") }, foreign_key: "developer_id", join_table: "developers_projects"
|
2011-05-23 22:05:06 -04:00
|
|
|
|
2012-03-21 18:18:18 -04:00
|
|
|
default_scope { includes(:projects) }
|
2011-05-23 22:05:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
class EagerDeveloperWithClassMethodDefaultScope < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
has_and_belongs_to_many :projects, -> { order("projects.id") }, foreign_key: "developer_id", join_table: "developers_projects"
|
2011-05-23 22:05:06 -04:00
|
|
|
|
|
|
|
def self.default_scope
|
|
|
|
includes(:projects)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class EagerDeveloperWithLambdaDefaultScope < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
has_and_belongs_to_many :projects, -> { order("projects.id") }, foreign_key: "developer_id", join_table: "developers_projects"
|
2011-05-23 22:05:06 -04:00
|
|
|
|
|
|
|
default_scope lambda { includes(:projects) }
|
|
|
|
end
|
|
|
|
|
|
|
|
class EagerDeveloperWithBlockDefaultScope < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
has_and_belongs_to_many :projects, -> { order("projects.id") }, foreign_key: "developer_id", join_table: "developers_projects"
|
2011-04-28 12:46:26 -04:00
|
|
|
|
2011-05-23 22:05:06 -04:00
|
|
|
default_scope { includes(:projects) }
|
|
|
|
end
|
|
|
|
|
|
|
|
class EagerDeveloperWithCallableDefaultScope < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2016-08-06 13:37:57 -04:00
|
|
|
has_and_belongs_to_many :projects, -> { order("projects.id") }, foreign_key: "developer_id", join_table: "developers_projects"
|
2011-05-23 22:05:06 -04:00
|
|
|
|
2016-08-06 13:37:57 -04:00
|
|
|
default_scope OpenStruct.new(call: includes(:projects))
|
2011-05-23 22:05:06 -04:00
|
|
|
end
|
2011-08-13 11:37:44 -04:00
|
|
|
|
|
|
|
class ThreadsafeDeveloper < ActiveRecord::Base
|
2016-08-06 12:26:20 -04:00
|
|
|
self.table_name = "developers"
|
2011-08-13 11:37:44 -04:00
|
|
|
|
|
|
|
def self.default_scope
|
2017-01-01 13:34:17 -05:00
|
|
|
Thread.current[:default_scope_delay].call
|
2011-08-13 11:37:44 -04:00
|
|
|
limit(1)
|
|
|
|
end
|
|
|
|
end
|
2012-12-10 14:22:30 -05:00
|
|
|
|
|
|
|
class CachedDeveloper < ActiveRecord::Base
|
2020-05-31 15:09:24 -04:00
|
|
|
include Developer::TimestampAliases
|
|
|
|
|
2012-12-10 14:22:30 -05:00
|
|
|
self.table_name = "developers"
|
|
|
|
self.cache_timestamp_format = :number
|
|
|
|
end
|
2016-12-28 14:15:49 -05:00
|
|
|
|
|
|
|
class DeveloperWithIncorrectlyOrderedHasManyThrough < ActiveRecord::Base
|
|
|
|
self.table_name = "developers"
|
|
|
|
has_many :companies, through: :contracts
|
|
|
|
has_many :contracts, foreign_key: :developer_id
|
|
|
|
end
|
2018-11-26 03:12:42 -05:00
|
|
|
|
|
|
|
class DeveloperName < ActiveRecord::Type::String
|
|
|
|
def deserialize(value)
|
|
|
|
"Developer: #{value}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class AttributedDeveloper < ActiveRecord::Base
|
|
|
|
self.table_name = "developers"
|
|
|
|
|
|
|
|
attribute :name, DeveloperName.new
|
|
|
|
|
|
|
|
self.ignored_columns += ["name"]
|
|
|
|
end
|
2019-10-28 17:41:11 -04:00
|
|
|
|
|
|
|
class ColumnNamesCachedDeveloper < ActiveRecord::Base
|
|
|
|
self.table_name = "developers"
|
|
|
|
self.ignored_columns += ["name"] if column_names.include?("name")
|
|
|
|
end
|