#
class AccessToken < OauthToken
- belongs_to :user
- belongs_to :client_application
+ belongs_to :user, :optional => true
+ belongs_to :client_application, :optional => true
scope :valid, -> { where(:invalidated_at => nil) }
#
class ClientApplication < ApplicationRecord
- belongs_to :user
+ belongs_to :user, :optional => true
has_many :tokens, :class_name => "OauthToken", :dependent => :delete_all
has_many :access_tokens
has_many :oauth2_verifiers
class Issue < ApplicationRecord
belongs_to :reportable, :polymorphic => true
- belongs_to :reported_user, :class_name => "User"
- belongs_to :user_resolved, :class_name => "User", :foreign_key => :resolved_by
- belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by
+ belongs_to :reported_user, :class_name => "User", :optional => true
+ belongs_to :user_resolved, :class_name => "User", :foreign_key => :resolved_by, :optional => true
+ belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by, :optional => true
has_many :reports, :dependent => :destroy
has_many :comments, :class_name => "IssueComment", :dependent => :destroy
class NoteComment < ApplicationRecord
belongs_to :note, :touch => true
- belongs_to :author, :class_name => "User"
+ belongs_to :author, :class_name => "User", :optional => true
validates :id, :uniqueness => true, :presence => { :on => :update },
:numericality => { :on => :update, :only_integer => true }
#
class OauthToken < ApplicationRecord
- belongs_to :client_application
- belongs_to :user
+ belongs_to :client_application, :optional => true
+ belongs_to :user, :optional => true
scope :authorized, -> { where("authorized_at IS NOT NULL and invalidated_at IS NULL") }
validate :validate_position
belongs_to :changeset
- belongs_to :redaction
+ belongs_to :redaction, :optional => true
belongs_to :current_node, :class_name => "Node", :foreign_key => "node_id"
has_many :old_tags, :class_name => "OldNodeTag", :foreign_key => [:node_id, :version]
include Redactable
belongs_to :changeset
- belongs_to :redaction
+ belongs_to :redaction, :optional => true
belongs_to :current_relation, :class_name => "Relation", :foreign_key => "relation_id"
has_many :old_members, -> { order(:sequence_id) }, :class_name => "OldRelationMember", :foreign_key => [:relation_id, :version]
include Redactable
belongs_to :changeset
- belongs_to :redaction
+ belongs_to :redaction, :optional => true
belongs_to :current_way, :class_name => "Way", :foreign_key => "way_id"
has_many :old_nodes, :class_name => "OldWayNode", :foreign_key => [:way_id, :version]
self.table_name = "gpx_files"
belongs_to :user, :counter_cache => true
- has_many :tags, :class_name => "Tracetag", :foreign_key => "gpx_id", :dependent => :delete_all, :inverse_of => "trace"
- has_many :points, :class_name => "Tracepoint", :foreign_key => "gpx_id", :dependent => :delete_all, :inverse_of => "trace"
+ has_many :tags, :class_name => "Tracetag", :foreign_key => "gpx_id", :dependent => :delete_all, :inverse_of => :trace
+ has_many :points, :class_name => "Tracepoint", :foreign_key => "gpx_id", :dependent => :delete_all, :inverse_of => :trace
scope :visible, -> { where(:visible => true) }
scope :visible_to, ->(u) { visible.where("visibility IN ('public', 'identifiable') OR user_id = ?", u) }
belongs_to :user, :class_name => "User"
belongs_to :creator, :class_name => "User"
- belongs_to :revoker, :class_name => "User"
+ belongs_to :revoker, :class_name => "User", :optional => true
PERIODS = Settings.user_block_periods
# This has defaulted to false since rails 6.0
config.action_view.default_enforce_utf8 = true
- # This defaults to true from rails 5.0 but our code doesn't comply
- # with it at all so we turn it off
- config.active_record.belongs_to_required_by_default = false unless Settings.status == "database_offline"
-
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types