]> git.openstreetmap.org Git - rails.git/commitdiff
Create an ApplicationRecord for models to inherit from
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 27 Nov 2019 10:50:48 +0000 (11:50 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 27 Nov 2019 10:50:48 +0000 (11:50 +0100)
This is the default for Rails 5+, and also paves the way for
multiple database support.

45 files changed:
.rubocop.yml
app/models/acl.rb
app/models/application_record.rb [new file with mode: 0644]
app/models/changeset.rb
app/models/changeset_comment.rb
app/models/changeset_tag.rb
app/models/client_application.rb
app/models/diary_comment.rb
app/models/diary_entry.rb
app/models/diary_entry_subscription.rb
app/models/friendship.rb
app/models/issue.rb
app/models/issue_comment.rb
app/models/language.rb
app/models/message.rb
app/models/node.rb
app/models/node_tag.rb
app/models/note.rb
app/models/note_comment.rb
app/models/oauth_nonce.rb
app/models/oauth_token.rb
app/models/old_node.rb
app/models/old_node_tag.rb
app/models/old_relation.rb
app/models/old_relation_member.rb
app/models/old_relation_tag.rb
app/models/old_way.rb
app/models/old_way_node.rb
app/models/old_way_tag.rb
app/models/redaction.rb
app/models/relation.rb
app/models/relation_member.rb
app/models/relation_tag.rb
app/models/report.rb
app/models/trace.rb
app/models/tracepoint.rb
app/models/tracetag.rb
app/models/user.rb
app/models/user_block.rb
app/models/user_preference.rb
app/models/user_role.rb
app/models/user_token.rb
app/models/way.rb
app/models/way_node.rb
app/models/way_tag.rb

index cbd62a052512bc82c9b6858a965391f206fb5327..18bf69b9b85be093b8e2f81147cd08180a7d869a 100644 (file)
@@ -38,9 +38,6 @@ Naming/FileName:
 Naming/UncommunicativeMethodParamName:
   Enabled: false
 
-Rails/ApplicationRecord:
-  Enabled: false
-
 Rails/CreateTableWithTimestamps:
   Enabled: false
 
index 895ed61e4de8883db9940f25c056222f4d2b6965..06f754c2274ad801fe34fc6e7369867d56e4397c 100644 (file)
@@ -17,7 +17,7 @@
 #  index_acls_on_mx       (mx)
 #
 
-class Acl < ActiveRecord::Base
+class Acl < ApplicationRecord
   validates :k, :presence => true
 
   def self.match(address, options = {})
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
new file mode 100644 (file)
index 0000000..10a4cba
--- /dev/null
@@ -0,0 +1,3 @@
+class ApplicationRecord < ActiveRecord::Base
+  self.abstract_class = true
+end
index 47f03c79544111eff476896c076d2cae2b6c31fb..990eae4077ae33b7b8968a9bd8542504432226c2 100644 (file)
@@ -25,7 +25,7 @@
 #  changesets_user_id_fkey  (user_id => users.id)
 #
 
-class Changeset < ActiveRecord::Base
+class Changeset < ApplicationRecord
   require "xml/libxml"
 
   belongs_to :user, :counter_cache => true
index 75b1a055b23dd1306a4469e4819d2cf531c2923d..ceb7d35597f75e816811214fbfa252eddd7470d0 100644 (file)
@@ -19,7 +19,7 @@
 #  changeset_comments_changeset_id_fkey  (changeset_id => changesets.id)
 #
 
-class ChangesetComment < ActiveRecord::Base
+class ChangesetComment < ApplicationRecord
   belongs_to :changeset
   belongs_to :author, :class_name => "User"
 
index 751029e03995c60835dc1d7eb0ab79a21fb48b3e..600ace4a6e498affc37cce96160289753fbd880e 100644 (file)
@@ -15,7 +15,7 @@
 #  changeset_tags_id_fkey  (changeset_id => changesets.id)
 #
 
-class ChangesetTag < ActiveRecord::Base
+class ChangesetTag < ApplicationRecord
   self.primary_keys = "changeset_id", "k"
 
   belongs_to :changeset
index ae95e2908a286793565915fd8f70577387df39c2..67ff075f1adb5bd1d8d6109077cdefd08233c26d 100644 (file)
@@ -30,7 +30,7 @@
 #  client_applications_user_id_fkey  (user_id => users.id)
 #
 
-class ClientApplication < ActiveRecord::Base
+class ClientApplication < ApplicationRecord
   belongs_to :user
   has_many :tokens, :class_name => "OauthToken", :dependent => :delete_all
   has_many :access_tokens
index 4ae21be8881922e49c799ba0868e93ba0f5e77f5..05f5044c5db779b232da81bd6e3bbdf0ba31d5b5 100644 (file)
@@ -22,7 +22,7 @@
 #  diary_comments_user_id_fkey         (user_id => users.id)
 #
 
-class DiaryComment < ActiveRecord::Base
+class DiaryComment < ApplicationRecord
   belongs_to :user
   belongs_to :diary_entry
 
index 4affe8b597f1269e92839fa201ba9bc683ee93e7..4ff1eeb35e57b0e8e3890dee62e2804761634215 100644 (file)
@@ -26,7 +26,7 @@
 #  diary_entries_user_id_fkey        (user_id => users.id)
 #
 
-class DiaryEntry < ActiveRecord::Base
+class DiaryEntry < ApplicationRecord
   belongs_to :user, :counter_cache => true
   belongs_to :language, :foreign_key => "language_code"
 
index 6e9a103adafac0d1315ecd1e956ff32cfc0abc2e..ed6de79e45de20ff7fcbc648b845a9c0f12fe652 100644 (file)
@@ -15,7 +15,7 @@
 #  diary_entry_subscriptions_user_id_fkey         (user_id => users.id)
 #
 
-class DiaryEntrySubscription < ActiveRecord::Base
+class DiaryEntrySubscription < ApplicationRecord
   self.primary_keys = "user_id", "diary_entry_id"
 
   belongs_to :user
index 27b25aee1b31313674db1d1578701873c921f160..476821b47ccdb221b31b603cfa97352611425c86 100644 (file)
@@ -17,7 +17,7 @@
 #  friends_user_id_fkey         (user_id => users.id)
 #
 
-class Friendship < ActiveRecord::Base
+class Friendship < ApplicationRecord
   self.table_name = "friends"
 
   belongs_to :befriender, :class_name => "User", :foreign_key => :user_id
index f18581b5f059670f01a52836aca272b2d77265fb..14c5f8231d56b95761cea9010cdb434230974e5e 100644 (file)
@@ -30,7 +30,7 @@
 #  issues_updated_by_fkey        (updated_by => users.id)
 #
 
-class Issue < ActiveRecord::Base
+class Issue < ApplicationRecord
   belongs_to :reportable, :polymorphic => true
   belongs_to :reported_user, :class_name => "User", :foreign_key => :reported_user_id
   belongs_to :user_resolved, :class_name => "User", :foreign_key => :resolved_by
index 0841295e1760120335d2e16ed79f57b20a9a67c2..69aa8bde931b398ff18e134412ba3886a259849f 100644 (file)
@@ -20,7 +20,7 @@
 #  issue_comments_user_id_fkey   (user_id => users.id)
 #
 
-class IssueComment < ActiveRecord::Base
+class IssueComment < ApplicationRecord
   belongs_to :issue
   belongs_to :user
 
index bb1aa4bd26016758ad3d8b66d09a7527a72b8ad8..cdf85a52bc3530cb11dc0eb3e0a05ed29d7f7a56 100644 (file)
@@ -7,7 +7,7 @@
 #  native_name  :string
 #
 
-class Language < ActiveRecord::Base
+class Language < ApplicationRecord
   self.primary_key = "code"
 
   has_many :diary_entries, :foreign_key => "language"
index 4ab129e9184f6593012bacd98c3de504ca06662c..44b1d8745e6fdf8600b6ff307c789599f08c7262 100644 (file)
@@ -24,7 +24,7 @@
 #  messages_to_user_id_fkey    (to_user_id => users.id)
 #
 
-class Message < ActiveRecord::Base
+class Message < ApplicationRecord
   belongs_to :sender, :class_name => "User", :foreign_key => :from_user_id
   belongs_to :recipient, :class_name => "User", :foreign_key => :to_user_id
 
index 2e71813ff948e853a429df6764b4ca375f220ce0..4d48112fc6fa9361fcd268f0e17b92b2a3d14776 100644 (file)
@@ -21,7 +21,7 @@
 #  current_nodes_changeset_id_fkey  (changeset_id => changesets.id)
 #
 
-class Node < ActiveRecord::Base
+class Node < ApplicationRecord
   require "xml/libxml"
 
   include GeoRecord
index 86404599b266de54e2896473cbb4abfdb0b10697..fa21b1ff6fdd60b2c813e7bd7979ee6b5a140837 100644 (file)
@@ -11,7 +11,7 @@
 #  current_node_tags_id_fkey  (node_id => current_nodes.id)
 #
 
-class NodeTag < ActiveRecord::Base
+class NodeTag < ApplicationRecord
   self.table_name = "current_node_tags"
   self.primary_keys = "node_id", "k"
 
index fa9d0b1ae6a5da75a25b02ddd6d204fe63267df8..ec57b770bbc008c923b2394e71f02e4d24549521 100644 (file)
@@ -18,7 +18,7 @@
 #  notes_updated_at_idx   (updated_at)
 #
 
-class Note < ActiveRecord::Base
+class Note < ApplicationRecord
   include GeoRecord
 
   has_many :comments, -> { left_joins(:author).where(:visible => true, :users => { :status => [nil, "active", "confirmed"] }).order(:created_at) }, :class_name => "NoteComment", :foreign_key => :note_id
index 448703ffa5f8d38471a7ecc2767f4ca41771af7b..9611cfe3af375861b865ec17582b0d278fae6c1f 100644 (file)
@@ -23,7 +23,7 @@
 #  note_comments_note_id_fkey    (note_id => notes.id)
 #
 
-class NoteComment < ActiveRecord::Base
+class NoteComment < ApplicationRecord
   belongs_to :note, :foreign_key => :note_id, :touch => true
   belongs_to :author, :class_name => "User", :foreign_key => :author_id
 
index 9d2773e8f346c5b8e6789c8a314020c7a39edd41..5f0920a96f1fd537456ff79ea0dd243a4883acda 100644 (file)
@@ -15,7 +15,7 @@
 
 # Simple store of nonces. The OAuth Spec requires that any given pair of nonce and timestamps are unique.
 # Thus you can use the same nonce with a different timestamp and viceversa.
-class OauthNonce < ActiveRecord::Base
+class OauthNonce < ApplicationRecord
   validates :timestamp, :presence => true
   validates :nonce, :presence => true, :uniqueness => { :scope => :timestamp }
 
index 5eeda48ba87ae7e13bb5ef923435f925c03bca6d..affdcdeb815b45b3c6d6ad32bf9c6526064ee45b 100644 (file)
@@ -35,7 +35,7 @@
 #  oauth_tokens_user_id_fkey                (user_id => users.id)
 #
 
-class OauthToken < ActiveRecord::Base
+class OauthToken < ApplicationRecord
   belongs_to :client_application
   belongs_to :user
 
index bdf8cb47ee32438ab875f7c5bc17d5b431fabef5..12099498e2de71edd681634fcbc64827a5e24390 100644 (file)
@@ -24,7 +24,7 @@
 #  nodes_redaction_id_fkey  (redaction_id => redactions.id)
 #
 
-class OldNode < ActiveRecord::Base
+class OldNode < ApplicationRecord
   include GeoRecord
   include ConsistencyValidations
   include ObjectMetadata
index a3e1c3aaf4a49d4a22d291ab942c7cc84b4e0f32..f2cba896cf031c7b8efbc14742e83977b197137c 100644 (file)
@@ -12,7 +12,7 @@
 #  node_tags_id_fkey  (node_id => nodes.node_id)
 #
 
-class OldNodeTag < ActiveRecord::Base
+class OldNodeTag < ApplicationRecord
   self.table_name = "node_tags"
   self.primary_keys = "node_id", "version", "k"
 
index 109f7d968da1eba835f1fbcd557048ce7cd8207b..c0025653fcaff9624279c37d13aa5abffc7ec0c5 100644 (file)
@@ -20,7 +20,7 @@
 #  relations_redaction_id_fkey  (redaction_id => redactions.id)
 #
 
-class OldRelation < ActiveRecord::Base
+class OldRelation < ApplicationRecord
   include ConsistencyValidations
   include ObjectMetadata
 
index f8d4a359f920cfca74818bb20c935b69deaf8af6..1714f3c859bc0df5d2af1d6f06bcd1151558db37 100644 (file)
@@ -18,7 +18,7 @@
 #  relation_members_id_fkey  (relation_id => relations.relation_id)
 #
 
-class OldRelationMember < ActiveRecord::Base
+class OldRelationMember < ApplicationRecord
   self.table_name = "relation_members"
   self.primary_keys = "relation_id", "version", "sequence_id"
 
index c674f708bc0214a097ccc27172a7bea0d7a2e488..d6e6e19c2dfb921a4f4621e22f9d83b08b5f86c1 100644 (file)
@@ -12,7 +12,7 @@
 #  relation_tags_id_fkey  (relation_id => relations.relation_id)
 #
 
-class OldRelationTag < ActiveRecord::Base
+class OldRelationTag < ApplicationRecord
   self.table_name = "relation_tags"
   self.primary_keys = "relation_id", "version", "k"
 
index 31e230c3869e2ee197f46a8de823834319536c5f..b515322e325cc1aed3face1f1f44166fa2f9b171 100644 (file)
@@ -20,7 +20,7 @@
 #  ways_redaction_id_fkey  (redaction_id => redactions.id)
 #
 
-class OldWay < ActiveRecord::Base
+class OldWay < ApplicationRecord
   include ConsistencyValidations
   include ObjectMetadata
 
index 836e76e47eb112e2764e6fc4c8876ab30cbdff17..d89227936aaf431b336f207b3aebcfe22538349a 100644 (file)
@@ -16,7 +16,7 @@
 #  way_nodes_id_fkey  (way_id => ways.way_id)
 #
 
-class OldWayNode < ActiveRecord::Base
+class OldWayNode < ApplicationRecord
   self.table_name = "way_nodes"
   self.primary_keys = "way_id", "version", "sequence_id"
 
index ae4ad605e70b1365f27d64c714b3085ec8f16603..90bf704b6af2c1a5be5eb7c4ea4107d488a16a85 100644 (file)
@@ -12,7 +12,7 @@
 #  way_tags_id_fkey  (way_id => ways.way_id)
 #
 
-class OldWayTag < ActiveRecord::Base
+class OldWayTag < ApplicationRecord
   self.table_name = "way_tags"
   self.primary_keys = "way_id", "version", "k"
 
index d9b2a5579c5bf3b72831649b5d4d04cc5ca41326..f4eedde0a2daddb172843d910507494261c1b4ae 100644 (file)
@@ -24,7 +24,7 @@
 # record's title and description fields, which can be
 # displayed linked from the redacted records.
 #
-class Redaction < ActiveRecord::Base
+class Redaction < ApplicationRecord
   belongs_to :user
 
   has_many :old_nodes
index a73d63183b44ee2b31dd7348f9d4e44e5e956c28..3f812d1b1a80c2c02e3a337524fb1cbce626650e 100644 (file)
@@ -17,7 +17,7 @@
 #  current_relations_changeset_id_fkey  (changeset_id => changesets.id)
 #
 
-class Relation < ActiveRecord::Base
+class Relation < ApplicationRecord
   require "xml/libxml"
 
   include ConsistencyValidations
index 7c399c3a88936b1769bb1657cf23c3db232d9e92..7f07dda9b82987226086f7d054e0a568d922f756 100644 (file)
@@ -17,7 +17,7 @@
 #  current_relation_members_id_fkey  (relation_id => current_relations.id)
 #
 
-class RelationMember < ActiveRecord::Base
+class RelationMember < ApplicationRecord
   self.table_name = "current_relation_members"
   self.primary_keys = "relation_id", "sequence_id"
 
index b186f505d13142bc751f28428f2f29ce8fc7b53f..ad9a932661bddc63e75eeb428fe00330c327e47b 100644 (file)
@@ -11,7 +11,7 @@
 #  current_relation_tags_id_fkey  (relation_id => current_relations.id)
 #
 
-class RelationTag < ActiveRecord::Base
+class RelationTag < ApplicationRecord
   self.table_name = "current_relation_tags"
   self.primary_keys = "relation_id", "k"
 
index 9bbf221df75c3cc0237044957321b6b372ed2da3..9afedb04ee29a68a0cabf434b549a22ff6dbd1f8 100644 (file)
@@ -21,7 +21,7 @@
 #  reports_user_id_fkey   (user_id => users.id)
 #
 
-class Report < ActiveRecord::Base
+class Report < ApplicationRecord
   belongs_to :issue, :counter_cache => true
   belongs_to :user
 
index f1cd72acd600f0ba2278b201c9427c8addaa91ae..d500784af882892ab065d8134fcfdf236c9be353 100644 (file)
@@ -25,7 +25,7 @@
 #  gpx_files_user_id_fkey  (user_id => users.id)
 #
 
-class Trace < ActiveRecord::Base
+class Trace < ApplicationRecord
   self.table_name = "gpx_files"
 
   belongs_to :user, :counter_cache => true
index 6473c943031134e87a1a9d99189a07614a9066ff..6352824fd7f08c3c50f781c95c80837c10302aab 100644 (file)
@@ -20,7 +20,7 @@
 #  gps_points_gpx_id_fkey  (gpx_id => gpx_files.id)
 #
 
-class Tracepoint < ActiveRecord::Base
+class Tracepoint < ApplicationRecord
   include GeoRecord
 
   self.table_name = "gps_points"
index 8d2f4ffface4d307c0d1013ec212781010c8879d..f13f7269fbb73625c712bcd7804a254b59661c63 100644 (file)
@@ -16,7 +16,7 @@
 #  gpx_file_tags_gpx_id_fkey  (gpx_id => gpx_files.id)
 #
 
-class Tracetag < ActiveRecord::Base
+class Tracetag < ApplicationRecord
   self.table_name = "gpx_file_tags"
 
   belongs_to :trace, :foreign_key => "gpx_id"
index 36ae0b55c9bf005274d8866231f50672a55dd1d8..6099823897473a04ab83a12e6ff90ef4fcb1e40f 100644 (file)
@@ -43,7 +43,7 @@
 #  users_home_idx                (home_tile)
 #
 
-class User < ActiveRecord::Base
+class User < ApplicationRecord
   require "xml/libxml"
 
   self.ignored_columns = ["nearby"]
index 92cee16cd6e96bcc57e4718042c00a9cc7d57d59..60f680ac3016e02b2d4b6acf4437658b26f01f5d 100644 (file)
@@ -24,7 +24,7 @@
 #  user_blocks_user_id_fkey       (user_id => users.id)
 #
 
-class UserBlock < ActiveRecord::Base
+class UserBlock < ApplicationRecord
   validate :moderator_permissions
   validates :reason, :characters => true
 
index 37bab38b0ccb7c6f5ff481e0efc234a01aa18d2d..d5cad3978c81f087cacee2b13f3e152aa87df506 100644 (file)
@@ -11,7 +11,7 @@
 #  user_preferences_user_id_fkey  (user_id => users.id)
 #
 
-class UserPreference < ActiveRecord::Base
+class UserPreference < ApplicationRecord
   self.primary_keys = "user_id", "k"
 
   belongs_to :user
index f3d48cade4bcfeb53df717b509cc0ab90ac45d39..a081361a76cb6db41fe03737c313db6fc08ddc45 100644 (file)
@@ -19,7 +19,7 @@
 #  user_roles_user_id_fkey     (user_id => users.id)
 #
 
-class UserRole < ActiveRecord::Base
+class UserRole < ApplicationRecord
   belongs_to :user
   belongs_to :granter, :class_name => "User"
 
index 844357d8d0242000db462047ea6be54bd01342c1..8c9bf4aeb36de68479d11533e406f9106877da4b 100644 (file)
@@ -18,7 +18,7 @@
 #  user_tokens_user_id_fkey  (user_id => users.id)
 #
 
-class UserToken < ActiveRecord::Base
+class UserToken < ApplicationRecord
   belongs_to :user
 
   after_initialize :set_defaults
index 3284c47f37312aed1215b64298e108ba86720c6b..d0d1e2a2e43836a52018a93213a2cc463850e4a8 100644 (file)
@@ -17,7 +17,7 @@
 #  current_ways_changeset_id_fkey  (changeset_id => changesets.id)
 #
 
-class Way < ActiveRecord::Base
+class Way < ApplicationRecord
   require "xml/libxml"
 
   include ConsistencyValidations
index 0788a631c8c9c3969ea79dc84988d81fd61f58b6..0626fb2403df19b013700617421c5accfd12c296 100644 (file)
@@ -16,7 +16,7 @@
 #  current_way_nodes_node_id_fkey  (node_id => current_nodes.id)
 #
 
-class WayNode < ActiveRecord::Base
+class WayNode < ApplicationRecord
   self.table_name = "current_way_nodes"
   self.primary_keys = "way_id", "sequence_id"
 
index 6637c158535694aa017e2719f79b067913cf9527..0d32d8c41631402f7b104b6b60b881308a9ab6c5 100644 (file)
@@ -11,7 +11,7 @@
 #  current_way_tags_id_fkey  (way_id => current_ways.id)
 #
 
-class WayTag < ActiveRecord::Base
+class WayTag < ApplicationRecord
   self.table_name = "current_way_tags"
   self.primary_keys = "way_id", "k"