optional belongs_to seem to be enforced now ????

This commit is contained in:
Andrew Brown 2019-12-15 12:36:19 -06:00
parent 5526e08427
commit 5ffd2bc074
135 changed files with 135 additions and 136 deletions

View File

@ -215,7 +215,8 @@ class ContentController < ApplicationController
successful_response(content_creation_redirect_url, t(:create_success, model_name: @content.try(:name).presence || humanized_model_name))
else
failed_response('new', :unprocessable_entity, "Unable to save page. Error code: " + @content.errors.map(&:messages).to_sentence)
raise "nope"
failed_response('new', :unprocessable_entity, "Unable to save page. Error code: " + @content.errors.to_json.to_s)
end
end

View File

@ -1,6 +1,5 @@
class Promotion < ApplicationRecord
belongs_to :user
belongs_to :page_unlock_promo_code
# belongs_to :promo_code, polymorphic: true

View File

@ -4,7 +4,7 @@ module BelongsToUniverse
extend ActiveSupport::Concern
included do
belongs_to :universe
belongs_to :universe, optional: true
scope :in_universe, ->(universe = nil) { where(universe: universe) unless universe.nil? }
end

View File

@ -2,7 +2,7 @@ class Document < ApplicationRecord
acts_as_paranoid
belongs_to :user
belongs_to :universe
belongs_to :universe, optional: true
has_many :document_analysis, dependent: :destroy
has_many :document_entities, through: :document_analysis

View File

@ -1,8 +1,7 @@
class ImageUpload < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :content, polymorphic: true
# This is the old way we uploaded files -- now we're transitioning to ActiveStorage's has_one_attached
has_attached_file :src,
path: 'content/uploads/:style/:filename',

View File

@ -1,7 +1,7 @@
class Archenemyship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :archenemy, class_name: 'Character'

View File

@ -1,7 +1,7 @@
class Artifactship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :religion
belongs_to :artifact, class_name: 'Item'

View File

@ -1,7 +1,7 @@
class BestFriendship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :best_friend, class_name: 'Character'

View File

@ -1,7 +1,7 @@
class Birthing < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :birthplace, class_name: 'Location'

View File

@ -3,7 +3,7 @@
class CapitalCitiesRelationship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :location
belongs_to :capital_city, class_name: 'Location'

View File

@ -1,5 +1,5 @@
class CharacterBirthtown < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :birthtown, class_name: Town.name
end

View File

@ -1,5 +1,5 @@
class CharacterCompanion < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :companion, class_name: Creature.name
end

View File

@ -1,5 +1,5 @@
class CharacterEnemy < ApplicationRecord
belongs_to :user, optional: true
belongs_to :character
belongs_to :user
belongs_to :enemy, class_name: Character.name
end

View File

@ -1,5 +1,5 @@
class CharacterFlora < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :flora
end

View File

@ -1,5 +1,5 @@
class CharacterFriend < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :friend, class_name: Character.name
end

View File

@ -1,5 +1,5 @@
class CharacterItem < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :item
end

View File

@ -1,7 +1,7 @@
class CharacterLoveInterest < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :love_interest, class_name: 'Character'
end

View File

@ -1,5 +1,5 @@
class CharacterMagic < ApplicationRecord
belongs_to :character
belongs_to :magic
belongs_to :user
belongs_to :user, optional: true
end

View File

@ -1,5 +1,5 @@
class CharacterTechnology < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :technology
end

View File

@ -1,7 +1,7 @@
class Childrenship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :child, class_name: 'Character'

View File

@ -1,5 +1,5 @@
class CountryCreature < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :country
belongs_to :creature
end

View File

@ -1,5 +1,5 @@
class CountryFlora < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :country
belongs_to :flora
end

View File

@ -1,5 +1,5 @@
class CountryGovernment < ApplicationRecord
belongs_to :country
belongs_to :government
belongs_to :user
belongs_to :user, optional: true
end

View File

@ -1,5 +1,5 @@
class CountryLandmark < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :country
belongs_to :landmark
end

View File

@ -1,5 +1,5 @@
class CountryLanguage < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :country
belongs_to :language
end

View File

@ -1,5 +1,5 @@
class CountryLocation < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :country
belongs_to :location
end

View File

@ -1,5 +1,5 @@
class CountryReligion < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :country
belongs_to :religion
end

View File

@ -1,5 +1,5 @@
class CountryTown < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :country
belongs_to :town
end

View File

@ -2,7 +2,7 @@ class CreatureRelationship < ApplicationRecord
include HasContentLinking
LINK_TYPE = :two_way
belongs_to :user
belongs_to :user, optional: true
belongs_to :creature
belongs_to :related_creature, class_name: 'Creature'

View File

@ -3,7 +3,7 @@
class CurrentOwnership < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :item
belongs_to :current_owner, class_name: 'Character'

View File

@ -1,5 +1,5 @@
class DeityAbility < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :ability, class_name: Magic.name
end

View File

@ -1,5 +1,5 @@
class DeityCharacterChild < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :character_child, class_name: Character.name
end

View File

@ -1,5 +1,5 @@
class DeityCharacterParent < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :character_parent, class_name: Character.name
end

View File

@ -1,5 +1,5 @@
class DeityCharacterPartner < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :character_partner, class_name: Character.name
end

View File

@ -3,5 +3,5 @@ class DeityCharacterSibling < ApplicationRecord
belongs_to :deity
belongs_to :character_sibling, class_name: Character.name
belongs_to :user
belongs_to :user, optional: true
end

View File

@ -1,5 +1,5 @@
class DeityCreature < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :creature
end

View File

@ -1,5 +1,5 @@
class DeityDeityChild < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :deity_child, class_name: Deity.name
end

View File

@ -1,5 +1,5 @@
class DeityDeityParent < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :deity_parent, class_name: Deity.name
end

View File

@ -1,5 +1,5 @@
class DeityDeityPartner < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :deity_partner, class_name: Deity.name
end

View File

@ -3,7 +3,7 @@ class DeityDeitySibling < ApplicationRecord
belongs_to :deity
belongs_to :deity_sibling, class_name: Deity.name
belongs_to :user
belongs_to :user, optional: true
after_create do
self.reciprocate(

View File

@ -1,5 +1,5 @@
class DeityFlora < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :flora
end

View File

@ -1,5 +1,5 @@
class DeityRace < ApplicationRecord
belongs_to :deity
belongs_to :race
belongs_to :user
belongs_to :user, optional: true
end

View File

@ -1,5 +1,5 @@
class DeityRelatedLandmark < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :related_landmark, class_name: Landmark.name
end

View File

@ -1,5 +1,5 @@
class DeityRelatedTown < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :related_town, class_name: Town.name
end

View File

@ -1,5 +1,5 @@
class DeityRelic < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :relic, class_name: Item.name
end

View File

@ -1,5 +1,5 @@
class DeityReligion < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :deity
belongs_to :religion
end

View File

@ -1,7 +1,7 @@
class Deityship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :religion
# This is hacky because we had Deityships pointing at character "deities" before

View File

@ -1,7 +1,7 @@
class FamousFigureship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :race
belongs_to :famous_figure, class_name: 'Character'

View File

@ -1,7 +1,7 @@
class Fathership < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :father, class_name: 'Character'

View File

@ -1,7 +1,7 @@
class FloraEatenBy < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :flora
belongs_to :creature

View File

@ -1,7 +1,7 @@
class FloraLocation < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :flora
belongs_to :location

View File

@ -1,7 +1,7 @@
class FloraMagicalEffect < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :flora
belongs_to :magic, class_name: 'Magic'

View File

@ -2,7 +2,7 @@ class FloraRelationship < ApplicationRecord
include HasContentLinking
LINK_TYPE = :two_way
belongs_to :user
belongs_to :user, optional: true
belongs_to :flora
belongs_to :related_flora, class_name: 'Flora'

View File

@ -1,5 +1,5 @@
class GovernmentCreature < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :government
belongs_to :creature
end

View File

@ -1,5 +1,5 @@
class GovernmentGroup < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :government
belongs_to :group
end

View File

@ -1,5 +1,5 @@
class GovernmentItem < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :government
belongs_to :item
end

View File

@ -1,5 +1,5 @@
class GovernmentLeader < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :government
belongs_to :leader, class_name: Character.name
end

View File

@ -1,5 +1,5 @@
class GovernmentPoliticalFigure < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :government
belongs_to :political_figure, class_name: Character.name
end

View File

@ -1,5 +1,5 @@
class GovernmentTechnology < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :government
belongs_to :technology
end

View File

@ -1,7 +1,7 @@
class GroupAllyship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :ally, class_name: 'Group'

View File

@ -1,7 +1,7 @@
class GroupClientship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :client, class_name: 'Group'

View File

@ -1,5 +1,5 @@
class GroupCreature < ApplicationRecord
belongs_to :group
belongs_to :creature
belongs_to :user
belongs_to :user, optional: true
end

View File

@ -1,7 +1,7 @@
class GroupEnemyship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :enemy, class_name: 'Group'

View File

@ -1,7 +1,7 @@
class GroupEquipmentship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :equipment, class_name: 'Item'

View File

@ -1,7 +1,7 @@
class GroupLeadership < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :leader, class_name: 'Character'

View File

@ -1,7 +1,7 @@
class GroupLocationship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :location

View File

@ -1,7 +1,7 @@
class GroupMembership < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :member, class_name: 'Character'

View File

@ -1,7 +1,7 @@
class GroupRivalship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :rival, class_name: 'Group'

View File

@ -1,7 +1,7 @@
class GroupSuppliership < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :supplier, class_name: 'Group'

View File

@ -1,7 +1,7 @@
class Headquartership < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :headquarter, class_name: 'Location'

View File

@ -1,5 +1,5 @@
class ItemMagic < ApplicationRecord
belongs_to :item
belongs_to :magic
belongs_to :user
belongs_to :user, optional: true
end

View File

@ -1,7 +1,7 @@
class KeyItemship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :key_item, class_name: 'Item'

View File

@ -1,5 +1,5 @@
class LandmarkCountry < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :landmark
belongs_to :country
end

View File

@ -1,5 +1,5 @@
class LandmarkCreature < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :landmark
belongs_to :creature
end

View File

@ -1,5 +1,5 @@
class LandmarkFlora < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :landmark
belongs_to :flora
end

View File

@ -1,5 +1,5 @@
class LandmarkNearbyTown < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :landmark
belongs_to :nearby_town, class_name: 'Town'

View File

@ -1,7 +1,7 @@
class LargestCitiesRelationship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :location
belongs_to :largest_city, class_name: 'Location'

View File

@ -1,7 +1,7 @@
class Lingualism < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :spoken_language, class_name: 'Language'

View File

@ -1,5 +1,5 @@
class LocationCapitalTown < ApplicationRecord
belongs_to :location
belongs_to :user
belongs_to :user, optional: true
belongs_to :capital_town, class_name: Town.name
end

View File

@ -1,5 +1,5 @@
class LocationLandmark < ApplicationRecord
belongs_to :location
belongs_to :landmark
belongs_to :user
belongs_to :user, optional: true
end

View File

@ -1,7 +1,7 @@
class LocationLanguageship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :location
belongs_to :language

View File

@ -1,5 +1,5 @@
class LocationLargestTown < ApplicationRecord
belongs_to :location
belongs_to :user
belongs_to :user, optional: true
belongs_to :largest_town, class_name: Town.name
end

View File

@ -1,7 +1,7 @@
class LocationLeadership < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :location
belongs_to :leader, class_name: 'Character'

View File

@ -1,5 +1,5 @@
class LocationNotableTown < ApplicationRecord
belongs_to :location
belongs_to :user
belongs_to :user, optional: true
belongs_to :notable_town, class_name: Town.name
end

View File

@ -1,7 +1,7 @@
class MagicDeityship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :magic
belongs_to :deity, class_name: 'Character'

View File

@ -3,7 +3,7 @@
class MakerRelationship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :item
belongs_to :maker, class_name: 'Character'

View File

@ -2,7 +2,7 @@ class Marriage < ApplicationRecord
include HasContentLinking
LINK_TYPE = :two_way
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :spouse, class_name: 'Character'

View File

@ -1,7 +1,7 @@
class Mothership < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :character
belongs_to :mother, class_name: 'Character'

View File

@ -3,7 +3,7 @@
class NotableCitiesRelationship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :location
belongs_to :notable_city, class_name: 'Location'

View File

@ -1,7 +1,7 @@
class Officeship < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :group
belongs_to :office, class_name: 'Location'

View File

@ -3,7 +3,7 @@
class OriginalOwnership < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :item
belongs_to :original_owner, class_name: 'Character'

View File

@ -3,7 +3,7 @@
class PastOwnership < ApplicationRecord
include HasContentLinking
belongs_to :user
belongs_to :user, optional: true
belongs_to :item
belongs_to :past_owner, class_name: 'Character'

View File

@ -1,5 +1,5 @@
class PlanetCountry < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :planet
belongs_to :country
end

View File

@ -1,5 +1,5 @@
class PlanetCreature < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :planet
belongs_to :creature
end

View File

@ -1,5 +1,5 @@
class PlanetDeity < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :planet
belongs_to :deity
end

View File

@ -1,5 +1,5 @@
class PlanetFlora < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :planet
belongs_to :flora
end

View File

@ -1,5 +1,5 @@
class PlanetGroup < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :planet
belongs_to :group
end

View File

@ -1,5 +1,5 @@
class PlanetLandmark < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :planet
belongs_to :landmark
end

View File

@ -1,5 +1,5 @@
class PlanetLanguage < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :planet
belongs_to :language
end

View File

@ -1,5 +1,5 @@
class PlanetLocation < ApplicationRecord
belongs_to :user
belongs_to :user, optional: true
belongs_to :planet
belongs_to :location
end

Some files were not shown because too many files have changed in this diff Show More