diff --git a/app/models/account_deletion.rb b/app/models/account_deletion.rb index bab962dca..cc9445310 100644 --- a/app/models/account_deletion.rb +++ b/app/models/account_deletion.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class AccountDeletion < ActiveRecord::Base +class AccountDeletion < ApplicationRecord include Diaspora::Federated::Base scope :uncompleted, -> { where('completed_at is null') } diff --git a/app/models/api/openid_connect/authorization.rb b/app/models/api/openid_connect/authorization.rb index 41c6c0e6f..00a373cad 100644 --- a/app/models/api/openid_connect/authorization.rb +++ b/app/models/api/openid_connect/authorization.rb @@ -2,7 +2,7 @@ module Api module OpenidConnect - class Authorization < ActiveRecord::Base + class Authorization < ApplicationRecord belongs_to :user belongs_to :o_auth_application diff --git a/app/models/api/openid_connect/o_auth_access_token.rb b/app/models/api/openid_connect/o_auth_access_token.rb index 053bc86df..176b4d04e 100644 --- a/app/models/api/openid_connect/o_auth_access_token.rb +++ b/app/models/api/openid_connect/o_auth_access_token.rb @@ -23,7 +23,7 @@ module Api module OpenidConnect - class OAuthAccessToken < ActiveRecord::Base + class OAuthAccessToken < ApplicationRecord belongs_to :authorization before_validation :setup, on: :create diff --git a/app/models/api/openid_connect/o_auth_application.rb b/app/models/api/openid_connect/o_auth_application.rb index ccceadfea..acf2817e4 100644 --- a/app/models/api/openid_connect/o_auth_application.rb +++ b/app/models/api/openid_connect/o_auth_application.rb @@ -25,7 +25,7 @@ require "digest" module Api module OpenidConnect - class OAuthApplication < ActiveRecord::Base + class OAuthApplication < ApplicationRecord has_many :authorizations, dependent: :destroy has_many :user, through: :authorizations diff --git a/app/models/api/openid_connect/pairwise_pseudonymous_identifier.rb b/app/models/api/openid_connect/pairwise_pseudonymous_identifier.rb index 7aeccc9fa..0b5643125 100644 --- a/app/models/api/openid_connect/pairwise_pseudonymous_identifier.rb +++ b/app/models/api/openid_connect/pairwise_pseudonymous_identifier.rb @@ -23,7 +23,7 @@ module Api module OpenidConnect - class PairwisePseudonymousIdentifier < ActiveRecord::Base + class PairwisePseudonymousIdentifier < ApplicationRecord self.table_name = "ppid" belongs_to :o_auth_application diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 000000000..10a4cba84 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/aspect.rb b/app/models/aspect.rb index dfacdc811..4f6054dce 100644 --- a/app/models/aspect.rb +++ b/app/models/aspect.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class Aspect < ActiveRecord::Base +class Aspect < ApplicationRecord belongs_to :user has_many :aspect_memberships, :dependent => :destroy diff --git a/app/models/aspect_membership.rb b/app/models/aspect_membership.rb index 8155c241f..8901f16a2 100644 --- a/app/models/aspect_membership.rb +++ b/app/models/aspect_membership.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class AspectMembership < ActiveRecord::Base +class AspectMembership < ApplicationRecord belongs_to :aspect belongs_to :contact diff --git a/app/models/aspect_visibility.rb b/app/models/aspect_visibility.rb index 88e645727..7a0eeba63 100644 --- a/app/models/aspect_visibility.rb +++ b/app/models/aspect_visibility.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class AspectVisibility < ActiveRecord::Base +class AspectVisibility < ApplicationRecord belongs_to :aspect validates :aspect, :presence => true diff --git a/app/models/block.rb b/app/models/block.rb index 1eba8f4c8..18f3109c4 100644 --- a/app/models/block.rb +++ b/app/models/block.rb @@ -1,4 +1,4 @@ -class Block < ActiveRecord::Base +class Block < ApplicationRecord belongs_to :person belongs_to :user diff --git a/app/models/comment.rb b/app/models/comment.rb index fb5446173..84fc383c7 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class Comment < ActiveRecord::Base +class Comment < ApplicationRecord include Diaspora::Federated::Base include Diaspora::Fields::Guid diff --git a/app/models/comment_signature.rb b/app/models/comment_signature.rb index 357bcb3b8..a4ef374ab 100644 --- a/app/models/comment_signature.rb +++ b/app/models/comment_signature.rb @@ -1,4 +1,4 @@ -class CommentSignature < ActiveRecord::Base +class CommentSignature < ApplicationRecord include Diaspora::Signature self.primary_key = :comment_id diff --git a/app/models/contact.rb b/app/models/contact.rb index c7970a2f9..440596736 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class Contact < ActiveRecord::Base +class Contact < ApplicationRecord include Diaspora::Federated::Base belongs_to :user diff --git a/app/models/conversation.rb b/app/models/conversation.rb index 4802d247e..f597af001 100644 --- a/app/models/conversation.rb +++ b/app/models/conversation.rb @@ -1,4 +1,4 @@ -class Conversation < ActiveRecord::Base +class Conversation < ApplicationRecord include Diaspora::Federated::Base include Diaspora::Fields::Guid include Diaspora::Fields::Author diff --git a/app/models/conversation_visibility.rb b/app/models/conversation_visibility.rb index 9c0afb2bd..39e7e66cd 100644 --- a/app/models/conversation_visibility.rb +++ b/app/models/conversation_visibility.rb @@ -1,4 +1,4 @@ -class ConversationVisibility < ActiveRecord::Base +class ConversationVisibility < ApplicationRecord belongs_to :conversation belongs_to :person @@ -6,7 +6,7 @@ class ConversationVisibility < ActiveRecord::Base after_destroy :check_orphan_conversation private - + def check_orphan_conversation conversation = Conversation.find_by_id(self.conversation.id) if conversation diff --git a/app/models/invitation_code.rb b/app/models/invitation_code.rb index 7b732359d..c88434b85 100644 --- a/app/models/invitation_code.rb +++ b/app/models/invitation_code.rb @@ -1,4 +1,4 @@ -class InvitationCode < ActiveRecord::Base +class InvitationCode < ApplicationRecord belongs_to :user validates_presence_of :user diff --git a/app/models/like.rb b/app/models/like.rb index 78eb9c3da..828d5b8aa 100644 --- a/app/models/like.rb +++ b/app/models/like.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class Like < ActiveRecord::Base +class Like < ApplicationRecord include Diaspora::Federated::Base include Diaspora::Fields::Guid include Diaspora::Fields::Author diff --git a/app/models/like_signature.rb b/app/models/like_signature.rb index 6978704a9..1024a5608 100644 --- a/app/models/like_signature.rb +++ b/app/models/like_signature.rb @@ -1,4 +1,4 @@ -class LikeSignature < ActiveRecord::Base +class LikeSignature < ApplicationRecord include Diaspora::Signature self.primary_key = :like_id diff --git a/app/models/location.rb b/app/models/location.rb index 0620104ad..37132f147 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,4 +1,4 @@ -class Location < ActiveRecord::Base +class Location < ApplicationRecord before_validation :split_coords, on: :create validates_presence_of :lat, :lng diff --git a/app/models/mention.rb b/app/models/mention.rb index 597cebe94..9fab1d195 100644 --- a/app/models/mention.rb +++ b/app/models/mention.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class Mention < ActiveRecord::Base +class Mention < ApplicationRecord belongs_to :mentions_container, polymorphic: true belongs_to :person validates :mentions_container, presence: true diff --git a/app/models/message.rb b/app/models/message.rb index 2a56ea47a..51ad27867 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -1,4 +1,4 @@ -class Message < ActiveRecord::Base +class Message < ApplicationRecord include Diaspora::Federated::Base include Diaspora::Fields::Guid include Diaspora::Fields::Author diff --git a/app/models/notification.rb b/app/models/notification.rb index c4b557045..f1adf5325 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. # -class Notification < ActiveRecord::Base +class Notification < ApplicationRecord belongs_to :recipient, class_name: "User" has_many :notification_actors, dependent: :destroy has_many :actors, class_name: "Person", through: :notification_actors, source: :person diff --git a/app/models/notification_actor.rb b/app/models/notification_actor.rb index 2b47a5cff..beaeefbb6 100644 --- a/app/models/notification_actor.rb +++ b/app/models/notification_actor.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class NotificationActor < ActiveRecord::Base +class NotificationActor < ApplicationRecord belongs_to :notification belongs_to :person diff --git a/app/models/o_embed_cache.rb b/app/models/o_embed_cache.rb index 17e6f073f..30967d1bd 100644 --- a/app/models/o_embed_cache.rb +++ b/app/models/o_embed_cache.rb @@ -1,4 +1,4 @@ -class OEmbedCache < ActiveRecord::Base +class OEmbedCache < ApplicationRecord serialize :data validates :data, :presence => true diff --git a/app/models/open_graph_cache.rb b/app/models/open_graph_cache.rb index ffae81c94..0aa0a2fe6 100644 --- a/app/models/open_graph_cache.rb +++ b/app/models/open_graph_cache.rb @@ -1,4 +1,4 @@ -class OpenGraphCache < ActiveRecord::Base +class OpenGraphCache < ApplicationRecord validates :title, :presence => true validates :ob_type, :presence => true validates :image, :presence => true diff --git a/app/models/participation.rb b/app/models/participation.rb index 94d82fb95..4bdda1a92 100644 --- a/app/models/participation.rb +++ b/app/models/participation.rb @@ -1,4 +1,4 @@ -class Participation < ActiveRecord::Base +class Participation < ApplicationRecord include Diaspora::Federated::Base include Diaspora::Fields::Guid include Diaspora::Fields::Author diff --git a/app/models/person.rb b/app/models/person.rb index 169a84c18..53eb8ed4d 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class Person < ActiveRecord::Base +class Person < ApplicationRecord include Diaspora::Fields::Guid # NOTE API V1 to be extracted diff --git a/app/models/photo.rb b/app/models/photo.rb index 17e9b9ff8..43ab064a3 100644 --- a/app/models/photo.rb +++ b/app/models/photo.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class Photo < ActiveRecord::Base +class Photo < ApplicationRecord include Diaspora::Federated::Base include Diaspora::Commentable include Diaspora::Shareable diff --git a/app/models/pod.rb b/app/models/pod.rb index dde1e28f1..b88c76cde 100644 --- a/app/models/pod.rb +++ b/app/models/pod.rb @@ -1,4 +1,4 @@ -class Pod < ActiveRecord::Base +class Pod < ApplicationRecord enum status: %i( unchecked no_errors diff --git a/app/models/poll.rb b/app/models/poll.rb index fa9033577..15589d601 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -1,4 +1,4 @@ -class Poll < ActiveRecord::Base +class Poll < ApplicationRecord include Diaspora::Federated::Base include Diaspora::Fields::Guid diff --git a/app/models/poll_answer.rb b/app/models/poll_answer.rb index 3387efe09..d91c4e13a 100644 --- a/app/models/poll_answer.rb +++ b/app/models/poll_answer.rb @@ -1,4 +1,4 @@ -class PollAnswer < ActiveRecord::Base +class PollAnswer < ApplicationRecord include Diaspora::Federated::Base include Diaspora::Fields::Guid diff --git a/app/models/poll_participation.rb b/app/models/poll_participation.rb index 7e653bb65..c5bb5395e 100644 --- a/app/models/poll_participation.rb +++ b/app/models/poll_participation.rb @@ -1,4 +1,4 @@ -class PollParticipation < ActiveRecord::Base +class PollParticipation < ApplicationRecord include Diaspora::Federated::Base include Diaspora::Fields::Guid include Diaspora::Fields::Author diff --git a/app/models/poll_participation_signature.rb b/app/models/poll_participation_signature.rb index 90701f286..001d83f7a 100644 --- a/app/models/poll_participation_signature.rb +++ b/app/models/poll_participation_signature.rb @@ -1,4 +1,4 @@ -class PollParticipationSignature < ActiveRecord::Base +class PollParticipationSignature < ApplicationRecord include Diaspora::Signature self.primary_key = :poll_participation_id diff --git a/app/models/post.rb b/app/models/post.rb index 58dbf12cf..fecaaf1bb 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class Post < ActiveRecord::Base +class Post < ApplicationRecord self.include_root_in_json = false include ApplicationHelper diff --git a/app/models/profile.rb b/app/models/profile.rb index 82413ccd2..3b903c1be 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class Profile < ActiveRecord::Base +class Profile < ApplicationRecord self.include_root_in_json = false include Diaspora::Federated::Base diff --git a/app/models/report.rb b/app/models/report.rb index a116e9083..171681977 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -1,4 +1,4 @@ -class Report < ActiveRecord::Base +class Report < ApplicationRecord validates :user_id, presence: true validates :item_id, presence: true validates :item_type, presence: true, inclusion: { diff --git a/app/models/role.rb b/app/models/role.rb index cbe5644ef..33711ebcf 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -1,6 +1,6 @@ # NOTE add the person object you want to attach role to... -class Role < ActiveRecord::Base +class Role < ApplicationRecord belongs_to :person validates :person, presence: true diff --git a/app/models/service.rb b/app/models/service.rb index 57322ce8c..890fc02bc 100644 --- a/app/models/service.rb +++ b/app/models/service.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class Service < ActiveRecord::Base +class Service < ApplicationRecord attr_accessor :provider, :info, :access_level belongs_to :user diff --git a/app/models/share_visibility.rb b/app/models/share_visibility.rb index bffdf91cc..25384bc37 100644 --- a/app/models/share_visibility.rb +++ b/app/models/share_visibility.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class ShareVisibility < ActiveRecord::Base +class ShareVisibility < ApplicationRecord belongs_to :user belongs_to :shareable, polymorphic: :true diff --git a/app/models/signature_order.rb b/app/models/signature_order.rb index 83cbfb51a..e65d0fae3 100644 --- a/app/models/signature_order.rb +++ b/app/models/signature_order.rb @@ -1,3 +1,3 @@ -class SignatureOrder < ActiveRecord::Base +class SignatureOrder < ApplicationRecord validates :order, presence: true, uniqueness: true end diff --git a/app/models/tag_following.rb b/app/models/tag_following.rb index 915221856..bd1cb62d2 100644 --- a/app/models/tag_following.rb +++ b/app/models/tag_following.rb @@ -1,4 +1,4 @@ -class TagFollowing < ActiveRecord::Base +class TagFollowing < ApplicationRecord belongs_to :user belongs_to :tag, :class_name => "ActsAsTaggableOn::Tag" diff --git a/app/models/user.rb b/app/models/user.rb index 2061efc9b..cd8d8e59c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -2,7 +2,7 @@ # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -class User < ActiveRecord::Base +class User < ApplicationRecord include AuthenticationToken include Connecting include Querying diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index ea4f92425..11ba7038d 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -1,4 +1,4 @@ -class UserPreference < ActiveRecord::Base +class UserPreference < ApplicationRecord belongs_to :user validate :must_be_valid_email_type diff --git a/db/migrate/20130717104359_migrate_activity_stream_to_status_message.rb b/db/migrate/20130717104359_migrate_activity_stream_to_status_message.rb index c02282f81..678cc8410 100644 --- a/db/migrate/20130717104359_migrate_activity_stream_to_status_message.rb +++ b/db/migrate/20130717104359_migrate_activity_stream_to_status_message.rb @@ -1,5 +1,5 @@ class MigrateActivityStreamToStatusMessage < ActiveRecord::Migration - class Post < ActiveRecord::Base; self.inheritance_column = false; end + class Post < ApplicationRecord; self.inheritance_column = false; end def up posts_stream_photos = Post.where(type: 'ActivityStreams::Photo') posts_stream_photos.each do |p| diff --git a/db/migrate/20160124234712_extend_pods.rb b/db/migrate/20160124234712_extend_pods.rb index 17fb6c215..d86769091 100644 --- a/db/migrate/20160124234712_extend_pods.rb +++ b/db/migrate/20160124234712_extend_pods.rb @@ -1,5 +1,5 @@ class ExtendPods < ActiveRecord::Migration - class Pod < ActiveRecord::Base + class Pod < ApplicationRecord has_many :people DEFAULT_PORTS = [URI::HTTP::DEFAULT_PORT, URI::HTTPS::DEFAULT_PORT] @@ -18,7 +18,7 @@ class ExtendPods < ActiveRecord::Migration end end - class Person < ActiveRecord::Base + class Person < ApplicationRecord belongs_to :owner, class_name: "User" belongs_to :pod @@ -27,7 +27,7 @@ class ExtendPods < ActiveRecord::Migration end end - class User < ActiveRecord::Base + class User < ApplicationRecord has_one :person, inverse_of: :owner, foreign_key: :owner_id end diff --git a/db/migrate/20160225232049_link_share_visibilities_with_user.rb b/db/migrate/20160225232049_link_share_visibilities_with_user.rb index 3292b0503..a31a2b0ef 100644 --- a/db/migrate/20160225232049_link_share_visibilities_with_user.rb +++ b/db/migrate/20160225232049_link_share_visibilities_with_user.rb @@ -1,5 +1,5 @@ class LinkShareVisibilitiesWithUser < ActiveRecord::Migration - class ShareVisibility < ActiveRecord::Base + class ShareVisibility < ApplicationRecord end def up diff --git a/db/migrate/20160302025129_cleanup_aspect_visibility.rb b/db/migrate/20160302025129_cleanup_aspect_visibility.rb index c937ac4df..18be29f05 100644 --- a/db/migrate/20160302025129_cleanup_aspect_visibility.rb +++ b/db/migrate/20160302025129_cleanup_aspect_visibility.rb @@ -1,5 +1,5 @@ class CleanupAspectVisibility < ActiveRecord::Migration - class AspectVisibility < ActiveRecord::Base + class AspectVisibility < ApplicationRecord end def up diff --git a/db/migrate/20160618033455_cleanup_participations.rb b/db/migrate/20160618033455_cleanup_participations.rb index ffe857885..42d4fdd3c 100644 --- a/db/migrate/20160618033455_cleanup_participations.rb +++ b/db/migrate/20160618033455_cleanup_participations.rb @@ -1,5 +1,5 @@ class CleanupParticipations < ActiveRecord::Migration - class Participation < ActiveRecord::Base + class Participation < ApplicationRecord end def up diff --git a/db/migrate/20160720212620_create_signature_tables.rb b/db/migrate/20160720212620_create_signature_tables.rb index f9e2d6c05..8bc82befc 100644 --- a/db/migrate/20160720212620_create_signature_tables.rb +++ b/db/migrate/20160720212620_create_signature_tables.rb @@ -1,5 +1,5 @@ class CreateSignatureTables < ActiveRecord::Migration - class SignatureOrder < ActiveRecord::Base + class SignatureOrder < ApplicationRecord end RELAYABLES = %i(comment like poll_participation).freeze diff --git a/db/migrate/20160807212443_participation_counter.rb b/db/migrate/20160807212443_participation_counter.rb index 871a1197f..fae1d9b03 100644 --- a/db/migrate/20160807212443_participation_counter.rb +++ b/db/migrate/20160807212443_participation_counter.rb @@ -1,18 +1,18 @@ class ParticipationCounter < ActiveRecord::Migration - class Comment < ActiveRecord::Base + class Comment < ApplicationRecord end - class Like < ActiveRecord::Base + class Like < ApplicationRecord end - class Participation < ActiveRecord::Base + class Participation < ApplicationRecord belongs_to :author, class_name: "Person" end - class Poll < ActiveRecord::Base + class Poll < ApplicationRecord end - class PollParticipation < ActiveRecord::Base + class PollParticipation < ApplicationRecord belongs_to :poll end diff --git a/db/migrate/20160810230114_cleanup_invitation_columns_from_users.rb b/db/migrate/20160810230114_cleanup_invitation_columns_from_users.rb index f51312b2f..895b75471 100644 --- a/db/migrate/20160810230114_cleanup_invitation_columns_from_users.rb +++ b/db/migrate/20160810230114_cleanup_invitation_columns_from_users.rb @@ -1,8 +1,8 @@ class CleanupInvitationColumnsFromUsers < ActiveRecord::Migration - class InvitationCode < ActiveRecord::Base + class InvitationCode < ApplicationRecord end - class User < ActiveRecord::Base + class User < ApplicationRecord end def change diff --git a/db/migrate/20160822212739_remove_started_sharing_notifications_without_contact.rb b/db/migrate/20160822212739_remove_started_sharing_notifications_without_contact.rb index 70a62f68f..f41f1d202 100644 --- a/db/migrate/20160822212739_remove_started_sharing_notifications_without_contact.rb +++ b/db/migrate/20160822212739_remove_started_sharing_notifications_without_contact.rb @@ -1,5 +1,5 @@ class RemoveStartedSharingNotificationsWithoutContact < ActiveRecord::Migration - class Notification < ActiveRecord::Base + class Notification < ApplicationRecord end def up diff --git a/db/migrate/20160902180630_remove_invalid_unconfirmed_emails.rb b/db/migrate/20160902180630_remove_invalid_unconfirmed_emails.rb index 086531c16..0e98b4499 100644 --- a/db/migrate/20160902180630_remove_invalid_unconfirmed_emails.rb +++ b/db/migrate/20160902180630_remove_invalid_unconfirmed_emails.rb @@ -1,5 +1,5 @@ class RemoveInvalidUnconfirmedEmails < ActiveRecord::Migration - class User < ActiveRecord::Base + class User < ApplicationRecord end def up diff --git a/db/migrate/20160906225138_fix_photos_share_visibilities.rb b/db/migrate/20160906225138_fix_photos_share_visibilities.rb index 3621fe28b..cd2627c8b 100644 --- a/db/migrate/20160906225138_fix_photos_share_visibilities.rb +++ b/db/migrate/20160906225138_fix_photos_share_visibilities.rb @@ -1,8 +1,8 @@ class FixPhotosShareVisibilities < ActiveRecord::Migration - class Photo < ActiveRecord::Base + class Photo < ApplicationRecord end - class ShareVisibility < ActiveRecord::Base + class ShareVisibility < ApplicationRecord end def up diff --git a/db/migrate/20161107100840_polymorphic_mentions.rb b/db/migrate/20161107100840_polymorphic_mentions.rb index 2f00e65fe..69bd3017a 100644 --- a/db/migrate/20161107100840_polymorphic_mentions.rb +++ b/db/migrate/20161107100840_polymorphic_mentions.rb @@ -17,10 +17,10 @@ class PolymorphicMentions < ActiveRecord::Migration reversible(&method(:up_down)) end - class Mention < ActiveRecord::Base + class Mention < ApplicationRecord end - class Notification < ActiveRecord::Base + class Notification < ApplicationRecord end def up_down(change) diff --git a/lib/share_visibility_converter.rb b/lib/share_visibility_converter.rb index c044570d3..82b9e2d23 100644 --- a/lib/share_visibility_converter.rb +++ b/lib/share_visibility_converter.rb @@ -1,24 +1,24 @@ #we dont have the environment, and it is not carring over from the migration unless defined?(Person) - class Person < ActiveRecord::Base + class Person < ApplicationRecord belongs_to :owner, :class_name => 'User' end end unless defined?(User) - class User < ActiveRecord::Base + class User < ApplicationRecord serialize :hidden_shareables, Hash end end unless defined?(Contact) - class Contact < ActiveRecord::Base + class Contact < ApplicationRecord belongs_to :user end end unless defined?(ShareVisibility) - class ShareVisibility < ActiveRecord::Base + class ShareVisibility < ApplicationRecord belongs_to :contact end end @@ -28,14 +28,14 @@ class ShareVisibilityConverter def self.copy_hidden_share_visibilities_to_users(only_recent = false) query = ShareVisibility.where(:hidden => true).includes(:contact => :user) query = query.where('share_visibilities.updated_at > ?', RECENT.weeks.ago) if only_recent - count = query.count + count = query.count puts "Updating #{count} records in batches of 1000..." batch_count = 1 query.find_in_batches do |visibilities| puts "Updating batch ##{batch_count} of #{(count/1000)+1}..." batch_count += 1 - visibilities.each do |visibility| + visibilities.each do |visibility| begin type = visibility.shareable_type id = visibility.shareable_id.to_s